-
Notifications
You must be signed in to change notification settings - Fork 1.3k
compiler set_qualname #5930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compiler set_qualname #5930
Conversation
WalkthroughThis change refactors how the qualified name ( Changes
Sequence Diagram(s)sequenceDiagram
participant Compiler
participant SymbolTable
participant CodeInfo
Compiler->>Compiler: push_output()
Compiler->>Compiler: set_qualname()
Compiler->>Compiler: make_qualname()
Compiler->>SymbolTable: inspect current scope, parent, stack
Compiler->>Compiler: compute qualified name string
Compiler->>CodeInfo: assign qualname
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yml 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)`**/*.rs`: Follow the default rustfmt code style (`cargo fmt` to format) Always ...
📄 Source: CodeRabbit Inference Engine (.github/copilot-instructions.md) List of files the instruction was applied to:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
🔇 Additional comments (8)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
compiler/codegen/src/compile.rs
(7 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.rs`: Follow the default rustfmt code style (`cargo fmt` to format) Always ...
**/*.rs
: Follow the default rustfmt code style (cargo fmt
to format)
Always run clippy to lint code (cargo clippy
) before completing tasks. Fix any warnings or lints that are introduced by your changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass
,pymodule
,pyfunction
, etc.) when implementing Python functionality in Rust
📄 Source: CodeRabbit Inference Engine (.github/copilot-instructions.md)
List of files the instruction was applied to:
compiler/codegen/src/compile.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: Run tests under miri
- GitHub Check: Run snippets and cpython tests (windows-latest)
- GitHub Check: Check the WASM package and demo
- GitHub Check: Run snippets and cpython tests on wasm-wasi
- GitHub Check: Run snippets and cpython tests (ubuntu-latest)
- GitHub Check: Run snippets and cpython tests (macos-latest)
- GitHub Check: Run rust tests (windows-latest)
- GitHub Check: Run rust tests (ubuntu-latest)
- GitHub Check: Run rust tests (macos-latest)
- GitHub Check: Check Rust code with rustfmt and clippy
- GitHub Check: Ensure compilation on various targets
🔇 Additional comments (5)
compiler/codegen/src/compile.rs (5)
405-406
: LGTM! Deferred qualname assignment aligns with the new centralized approach.The change to initialize
qualname
asNone
and set it later viaset_qualname
is appropriate for the refactoring.
497-507
: Verify the logic when code stack size exceeds symbol table stack size.The condition
stack_size > self.symbol_table_stack.len()
suggests we're in a state where the symbol table hasn't been pushed yet. While the comment acknowledges this, it would be good to verify that this is the expected behavior and doesn't indicate a timing issue.Can you confirm that this condition is expected during normal compilation flow? It might be worth adding more detailed documentation about when this state occurs.
1598-1600
: Appropriate placement of qualname computation for functions.The
set_qualname
call is correctly placed after entering the function and setting up the context, ensuring all necessary information is available for proper qualname generation.
1824-1826
: Correct qualname computation for class definitions.The placement after
push_output
ensures the symbol table and code stack are properly set up for accurate qualname generation.
545-552
: Qualified_path duplication guard validatedWe searched the codebase for nested modules and functions sharing the same name and found no instances where a parent and child scope use identical identifiers. The check
self.qualified_path[path_len - 1] == current_obj_nametherefore correctly avoids duplicate segments in the qualified path without risk of skipping a deeper, distinct scope. No changes are needed.
Summary by CodeRabbit