Skip to content

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

Merged
Araq merged 1 commit into
develfrom
pr_yt
May 27, 2026
Merged

fixes #22791; ProveField warning with nested case object#25774
Araq merged 1 commit into
develfrom
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".

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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
@Araq Araq merged commit 3e2cea2 into devel May 27, 2026
25 checks passed
@Araq Araq deleted the pr_yt branch May 27, 2026 21:29
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from 3e2cea2

Hint: mm: orc; opt: speed; options: -d:release
192380 lines; 12.826s; 801.477MiB peakmem

narimiran pushed a commit that referenced this pull request May 28, 2026
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

* Added a new test in `tests/objvariant/tcorrectcheckedfield.nim` for
bug #22791, verifying correct pattern matching and field access in
nested `case` objects with constants.

(cherry picked from commit 3e2cea2)
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

3 participants