Skip to content

Fix symtable type_param_block name#8137

Merged
youknowone merged 1 commit into
RustPython:mainfrom
ShaharNaveh:symtable-type-param-name
Jun 22, 2026
Merged

Fix symtable type_param_block name#8137
youknowone merged 1 commit into
RustPython:mainfrom
ShaharNaveh:symtable-type-param-name

Conversation

@ShaharNaveh

@ShaharNaveh ShaharNaveh commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Summary by CodeRabbit

  • Chores
    • Updated internal symbol scope handling to improve code maintainability and consistency across the system.

@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 7cdfb320-cb4f-4f15-bf6f-48c71a08d5a5

📥 Commits

Reviewing files that changed from the base of the PR and between fe2a7db and 1c4fddb.

⛔ Files ignored due to path filters (1)
  • Lib/test/test_symtable.py is excluded by !Lib/**
📒 Files selected for processing (2)
  • crates/codegen/src/symboltable.rs
  • crates/vm/src/stdlib/_symtable.rs

📝 Walkthrough

Walkthrough

Adds pub const fn as_i32(&self) -> i32 and From<SymbolScope> for i32 to SymbolScope in symboltable.rs. These are then used in _symtable.rs to replace hard-coded scope integer constants. TYPE_TYPE_VAR_BOUND is removed and the remaining type constants are renumbered. TypeParams scope names are simplified to raw symbol names.

Changes

SymbolScope numeric conversion and symtable constant alignment

Layer / File(s) Summary
SymbolScope::as_i32 and From<SymbolScope> for i32
crates/codegen/src/symboltable.rs
Adds pub const fn as_i32(&self) -> i32 mapping each SymbolScope variant to a CPython-compatible integer, plus a From<SymbolScope> for i32 impl delegating to as_i32.
Symtable exported constants and TypeParams scope names
crates/vm/src/stdlib/_symtable.rs, crates/codegen/src/symboltable.rs
Replaces hard-coded integer literals for LOCAL, GLOBAL_EXPLICIT, GLOBAL_IMPLICIT, FREE, CELL with SymbolScope::*.as_i32() calls; places SCOPE_OFFSET; removes TYPE_TYPE_VAR_BOUND and renumbers TYPE_TYPE_ALIAS (5→4), TYPE_TYPE_PARAMETERS (6→5), TYPE_TYPE_VARIABLE (7→6). Updates enter_type_param_block calls for generic functions, classes, and type aliases to use raw names instead of "<generic parameters of ...>" formatted strings.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A rabbit hops through numeric lands,
Where scope constants once were set by hand.
Now as_i32 maps each name with care,
TYPE_VAR_BOUND vanished into air!
The numbers shift, the names grow plain —
CPython and RustPython aligned again. 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix symtable type_param_block name' directly corresponds to the main change in the PR: modifying how scope names are passed in enter_type_param_block() for generic definitions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

📦 Library Dependencies

The following Lib/ modules were modified. Here are their dependencies:

[x] lib: cpython/Lib/symtable.py
[x] test: cpython/Lib/test/test_symtable.py (TODO: 15)

dependencies:

  • symtable

dependent tests: (2 tests)

  • symtable: test_inspect test_symtable

Legend:

  • [+] path exists in CPython
  • [x] up-to-date, [ ] outdated

@youknowone youknowone merged commit 8214c90 into RustPython:main Jun 22, 2026
50 of 51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants