Always load __debug__ as a const.

This commit is contained in:
DimitrisJim 2023-02-26 09:23:07 +02:00
parent 8b9f57906a
commit ce5cdd1bcb

View file

@ -500,6 +500,14 @@ impl Compiler {
// // TODO: is this right?
// SymbolScope::Unknown => NameOpType::Global,
};
if NameUsage::Load == usage && name == "__debug__" {
self.emit_constant(ConstantData::Boolean {
value: self.opts.optimize == 0,
});
return Ok(());
}
let mut idx = cache
.get_index_of(name.as_ref())
.unwrap_or_else(|| cache.insert_full(name.into_owned()).0);