Skip to content

Commit c6c4d45

Browse files
committed
Revert interactive print nesting check
The in_conditional_block check was incorrect. CPython's c_nestlevel only tracks function/class scopes, not compound blocks. Expression statements inside if/for/while/try/with at module level should still be auto-printed in interactive mode.
1 parent 6d17c83 commit c6c4d45

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crates/codegen/src/compile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2156,7 +2156,7 @@ impl Compiler {
21562156
ast::Stmt::Expr(ast::StmtExpr { value, .. }) => {
21572157
self.compile_expression(value)?;
21582158

2159-
if self.interactive && !self.ctx.in_func() && !self.ctx.in_class && self.current_code_info().in_conditional_block == 0 {
2159+
if self.interactive && !self.ctx.in_func() && !self.ctx.in_class {
21602160
emit!(
21612161
self,
21622162
Instruction::CallIntrinsic1 {

0 commit comments

Comments
 (0)