| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
📝 Walkthrough
WalkthroughThis PR renames symbol-table flags to the new DEF_*/USE scheme across codegen, symbol analysis, and Python symtable bindings. It updates comprehension, free-class, global/nonlocal, parameter, and annotation handling, plus matching tests and exported constants. ChangesSymbol flag migration across analyzer, codegen, and symtable API
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem🚥 Pre-merge checks | ✅ 4 | ❌ 1 ❌ Failed checks (1 warning)
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. ❤️ ShareComment @coderabbitai help to get the list of available commands. |
Sorry, something went wrong.
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] lib: cpython/Lib/symtable.py dependencies:
dependent tests: (2 tests)
Legend:
|
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agentsVerify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Inline comments: In `@crates/codegen/src/symboltable.rs`: - Around line 311-317: `SymbolFlags::DEF_BOUND` is currently mixing in the RustPython-only `ITER` bit, which leaks into the public `_symtable.DEF_BOUND` export and breaks CPython compatibility. Update the `DEF_BOUND` definition in `symboltable.rs` to include only the CPython-aligned flags, and keep `ITER` restricted to internal bound-check logic elsewhere in the symbol table handling.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 4c981d47-0be7-4e02-802a-f6f0517ef402
📥 CommitsReviewing files that changed from the base of the PR and between 0009dd6 and 560b9cb.
⛔ Files ignored due to path filters (1)
Sorry, something went wrong.
| const DEF_BOUND = ( | ||
| Self::DEF_LOCAL.bits() | ||
| | Self::DEF_PARAM.bits() | ||
| | Self::DEF_IMPORT.bits() | ||
| | Self::ITER.bits() | ||
| | Self::DEF_TYPE_PARAM.bits() | ||
| ); |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Keep RustPython-only ITER out of the CPython DEF_BOUND mask.
Line 315 folds the internal ITER bit into DEF_BOUND, and _symtable now exports SymbolFlags::DEF_BOUND.bits() directly. That makes the public _symtable.DEF_BOUND value include a RustPython-specific flag, breaking the CPython-aligned flag contract. Keep DEF_BOUND CPython-compatible and include ITER only in internal bound checks.
Suggested fix const DEF_BOUND = (
Self::DEF_LOCAL.bits()
| Self::DEF_PARAM.bits()
| Self::DEF_IMPORT.bits()
- | Self::ITER.bits()
| Self::DEF_TYPE_PARAM.bits()
); pub const fn is_bound(&self) -> bool {
- self.flags.intersects(SymbolFlags::DEF_BOUND)
+ self.flags
+ .intersects(SymbolFlags::DEF_BOUND | SymbolFlags::ITER)
}‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const DEF_BOUND = ( | |
| Self::DEF_LOCAL.bits() | |
| | Self::DEF_PARAM.bits() | |
| | Self::DEF_IMPORT.bits() | |
| | Self::ITER.bits() | |
| | Self::DEF_TYPE_PARAM.bits() | |
| ); | |
| const DEF_BOUND = ( | |
| Self::DEF_LOCAL.bits() | |
| | Self::DEF_PARAM.bits() | |
| | Self::DEF_IMPORT.bits() | |
| | Self::DEF_TYPE_PARAM.bits() | |
| ); |
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/codegen/src/symboltable.rs` around lines 311 - 317, `SymbolFlags::DEF_BOUND` is currently mixing in the RustPython-only `ITER` bit, which leaks into the public `_symtable.DEF_BOUND` export and breaks CPython compatibility. Update the `DEF_BOUND` definition in `symboltable.rs` to include only the CPython-aligned flags, and keep `ITER` restricted to internal bound-check logic elsewhere in the symbol table handling.
Sorry, something went wrong.
| const DEF_GLOBAL = 1; | ||
| const DEF_LOCAL = 2; | ||
| const DEF_PARAM = 2 << 1; | ||
| const DEF_NONLOCAL = 2 << 2; | ||
| const USE = 2 << 3; |
There was a problem hiding this comment.
| const DEF_GLOBAL = 1; | |
| const DEF_LOCAL = 2; | |
| const DEF_PARAM = 2 << 1; | |
| const DEF_NONLOCAL = 2 << 2; | |
| const USE = 2 << 3; | |
| const DEF_GLOBAL = 1 << 0; | |
| const DEF_LOCAL = 1 << 1; | |
| const DEF_PARAM = 1 << 2; | |
| const DEF_NONLOCAL = 1 << 3; | |
| const USE = 1 << 4; |
if 2 << n better than this?
Sorry, something went wrong.
There was a problem hiding this comment.
I've matched those values to be 1:1 like they're defined over at CPython for it to not be confusing. I'd rather keep it like this if you're okay with it
Sorry, something went wrong.
There was a problem hiding this comment.
aligning to original code is better. I still am curious why CPython did it though.
Sorry, something went wrong.
* ASSIGNED -> DEF_LOCAL * GLOBAL -> DEF_GLOBAL * REFERENCED -> USE * PARAMETER -> DEF_PARAM * expose symbol flags directly as a pyattr * FREE_CLASS -> DEF_FREE_CLASS * IMPORTED -> DEF_IMPORT * ANNOTATED -> DEF_ANNOT * DEF_COMP_ITER DEF_COMP_CELL DEF_TYPE_PARAM * DEF_NONLOCAL DEF_BOUND * Align flag values * unmark passing tests
| Back | FazBrowse Home | New Git URL |
Summary
Summary by CodeRabbit