Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Symboltable updates#5861

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
arihant2math wants to merge1 commit intoRustPython:main
base:main
Choose a base branch
Loading
fromarihant2math:symtable

Conversation

arihant2math
Copy link
Collaborator

@arihant2matharihant2math commentedJun 28, 2025
edited by coderabbitaibot
Loading

I used the cpython implementation as a reference and implemented a few features/bug-fixes.

Summary by CodeRabbit

  • New Features

    • Improved error detection for duplicate parameter names in function definitions.
    • Added clearer error messages when using star imports (import *) outside the module-level scope.
  • Bug Fixes

    • Enhanced handling of type parameters and comprehensions for more precise and consistent behavior.
  • Refactor

    • Refined internal symbol handling to better align with standard Python behavior.

@coderabbitaicoderabbitai
Copy link
Contributor

coderabbitaibot commentedJun 28, 2025
edited
Loading

Walkthrough

The changes update symbol flag definitions and symbol usage handling in the symbol table to align more closely with CPython. New flags and a TypeParam symbol usage are introduced, error checks for duplicate parameters and star imports are added, and comprehension/type parameter handling is refined for accuracy and consistency.

Changes

File(s)Change Summary
compiler/codegen/src/symboltable.rsAdded new symbol flags (GLOBAL, COMP_ITER, COMP_CELL, TYPE_PARAM); extended BOUND; added SymbolUsage::TypeParam; improved duplicate parameter and star import error detection; refined comprehension and type parameter symbol registration and context handling; updated error messages.

Sequence Diagram(s)

sequenceDiagram    participant User    participant SymbolTableBuilder    participant SymbolTable    User->>SymbolTableBuilder: Define function with parameters    SymbolTableBuilder->>SymbolTable: Register parameter name    alt Duplicate parameter        SymbolTableBuilder-->>User: Return duplicate parameter error    end    User->>SymbolTableBuilder: Write import * statement    SymbolTableBuilder->>SymbolTable: Check scope    alt Not at module scope        SymbolTableBuilder-->>User: Return star import error    end    User->>SymbolTableBuilder: Define comprehension/type parameter    SymbolTableBuilder->>SymbolTable: Register symbol with TypeParam usage and flags
Loading

Poem

In the warren of code, new flags now appear,
TypeParams and globals, their meanings are clear.
Comprehensions refined, imports checked with care,
No duplicate names will slip unaware.
With symbols in order, the table stands tall—
A rabbit’s delight in the logic of all! 🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between07a04ac and0cd6193.

📒 Files selected for processing (1)
  • compiler/codegen/src/symboltable.rs (12 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CRPR: RustPython/RustPython#0File: .github/copilot-instructions.md:0-0Timestamp: 2025-06-26T12:52:11.138ZLearning: To find unimplemented methods and contribution opportunities, run './whats_left.py' in the RustPython repository.
compiler/codegen/src/symboltable.rs (2)
Learnt from: morealPR: RustPython/RustPython#5847File: vm/src/stdlib/stat.rs:547-567Timestamp: 2025-06-27T14:47:28.810ZLearning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration using #ifdef checks rather than providing fallback values for other platforms.
Learnt from: morealPR: RustPython/RustPython#5847File: vm/src/stdlib/stat.rs:547-567Timestamp: 2025-06-27T14:47:28.810ZLearning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration rather than providing fallback values for other platforms.
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: Run tests under miri
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Run snippets and cpython tests on wasm-wasi
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Run snippets and cpython tests (windows-latest)
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Ensure compilation on various targets
  • GitHub Check: Run rust tests (windows-latest)
  • GitHub Check: Check Rust code with rustfmt and clippy
🔇 Additional comments (10)
compiler/codegen/src/symboltable.rs (10)

119-148:LGTM! Well-documented flag additions that align with CPython.

The new symbol flags (GLOBAL, COMP_ITER, COMP_CELL, TYPE_PARAM) and the extension of BOUND to include TYPE_PARAM are correctly implemented with unique bit values and clear CPython references.


565-566:Consistent addition of TypeParam variant.

The new TypeParam variant correctly corresponds to the TYPE_PARAM flag and enables proper differentiation of type parameter symbols.


581-581:Acceptable temporary annotation.

The#[allow(dead_code)] annotation with future usage comment is reasonable if IterDefinitionExp is planned for future implementation.


651-666:Excellent addition of duplicate parameter validation.

The duplicate parameter check correctly prevents invalid function definitions and provides clear error messages with precise location information.


822-833:Correct implementation of star import restrictions.

The validation properly enforces Python's rule that star imports are only allowed at module level, with appropriate error handling and symbol registration behavior.


1285-1288:Correct comprehension scoping implementation.

The changes properly handle the first generator's iterable in the outer scope and use the appropriate Load context for all iterables, aligning with Python's comprehension semantics.

Also applies to: 1299-1299


1313-1313:Proper type parameter symbol registration.

Type parameters are now correctly registered with SymbolUsage::TypeParam, providing accurate semantic differentiation from regular assignments.

Also applies to: 1323-1323, 1330-1330


1534-1534:Simplified error message aligns with CPython.

The fixed error message for nonlocal declarations at module level is clear and consistent with CPython's behavior.


1572-1585:Complete flag handling for Global and TypeParam symbols.

The additions correctly set the GLOBAL flag for global symbols and appropriately handle TypeParam with both ASSIGNED and TYPE_PARAM flags.


1589-1599:Improved clarity in comprehension iterator rebinding check.

The refined check with separate flag verification and inclusion of the symbol name in the error message provides better precision and debugging information.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat withCodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag@coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag@coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on oursupport 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings togenerate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add@coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add@coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add@coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a.coderabbit.yaml file to the root of your repository.
  • Please see theconfiguration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit ourDocumentation for detailed information on how to use CodeRabbit.
  • Join ourDiscord Community to get help, request features, and share feedback.
  • Follow us onX/Twitter for updates and announcements.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@arihant2math

[8]ページ先頭

©2009-2025 Movatter.jp