codegen: module seed CodeInfo emits empty flags#7782
Conversation
CPython convention: top-level module / interactive / expression code does not carry CO_NEWLOCALS or CO_OPTIMIZED. The per-scope mapping at enter_scope::CompilerScope::Module already returns empty flags, but Compiler::new seeded the root CodeInfo with CodeFlags::NEWLOCALS, forcing module code into the NEWLOCALS arm of frame.rs:725-731 so locals were allocated as a fresh empty dict instead of being bound to globals (the correct semantics for exec(code, globals)). Restore the seed to empty() so it matches the per-scope mapping and CPython's compiler_enter_scope for module scope.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe ChangesCode Generation Flag Alignment
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary by CodeRabbit