fix(gnovm): allow type-switch with sole case nil: (preprocess single-case branch must tag-type-only when ct is nil)#5766
Open
ltzmaxwell wants to merge 4 commits into
Open
fix(gnovm): allow type-switch with sole case nil: (preprocess single-case branch must tag-type-only when ct is nil)#5766ltzmaxwell wants to merge 4 commits into
case nil: (preprocess single-case branch must tag-type-only when ct is nil)#5766ltzmaxwell wants to merge 4 commits into
Conversation
…e-case branch must tag-type-only when ct is nil)
Collaborator
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):No automated checks match this pull request. ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
davd-gzl
approved these changes
Jun 2, 2026
Reserve() remains the legitimate entry point for nil-typed placeholder slots; Define() is for real bindings only. Catches the type-switch `case nil:` class of bug at the offending caller instead of as a confusing downstream "name not declared" panic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
case nil:(e.g.switch xx := x.(type) { case nil: ... }) panicked at preprocess withname xx not declaredbecause the single-case shortcut registered the switch var withanyValue(ct)wherect == nil; after: the sole-nilform is accepted andxxis bound to the tag's static type, matching Go.preprocess1's*TypeSwitchStmtbranch ingnovm/pkg/gnolang/preprocess.gonow gates thelen(n.Cases) == 1define-with-case-type shortcut onct != nil, so a nilctfalls through to the same tag-type define used for multi-case switches.gnovm/tests/files/typeswitch1.gnomirrors gocorpus's typeswitch1 (solecase nil:alongside mixed multi-type cases) and exercises both thexx := x.(type)and barexx.(type)shapes.