Skip to content

Commit ce5cdd1

Browse files
committed
Always load __debug__ as a const.
1 parent 8b9f579 commit ce5cdd1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

codegen/src/compile.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,14 @@ impl Compiler {
500500
// // TODO: is this right?
501501
// SymbolScope::Unknown => NameOpType::Global,
502502
};
503+
504+
if NameUsage::Load == usage && name == "__debug__" {
505+
self.emit_constant(ConstantData::Boolean {
506+
value: self.opts.optimize == 0,
507+
});
508+
return Ok(());
509+
}
510+
503511
let mut idx = cache
504512
.get_index_of(name.as_ref())
505513
.unwrap_or_else(|| cache.insert_full(name.into_owned()).0);

0 commit comments

Comments
 (0)