Skip to content

fixes #22791; ProveField warning with nested case object#25774

Open
ringabout wants to merge 1 commit intodevelfrom
pr_yt
Open

fixes #22791; ProveField warning with nested case object#25774
ringabout wants to merge 1 commit intodevelfrom
pr_yt

Conversation

@ringabout
Copy link
Copy Markdown
Member

fixes #22791

This pull request introduces a minor improvement to the handling of immutable variables in the compiler and adds a new test case for nested case objects. The most important changes are:

Compiler improvements

  • Updated the isLet guard in compiler/guards.nim to recognize skConst symbols as immutable variables, ensuring that constants are correctly identified alongside lets and other immutable types.

Test coverage

; ProveField warning with nested case object
Copilot AI review requested due to automatic review settings April 27, 2026 12:12
@ringabout
Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Nim issue #22791 by improving the compiler’s immutability detection for guard reasoning, ensuring const symbols are treated as immutable (like let) so nested case object field accessibility can be proven without triggering ProveField warnings.

Changes:

  • Extend compiler/guards.nim:isLet to treat skConst symbols as immutable for guard analysis.
  • Add a regression test covering nested case object access through a const instance under ProveField + strictCaseObjects.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
compiler/guards.nim Treats skConst as immutable in isLet, enabling guard proofs to apply to const bindings.
tests/objvariant/tcorrectcheckedfield.nim Adds a regression case reproducing #22791 with nested case objects and const instance access.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/objvariant/tcorrectcheckedfield.nim
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.

ProveField warning with nested case object

2 participants