Repository navigation
Fix nested named-field patterns that use no inner field - #138
Open
quinnj-bot[bot] wants to merge 2 commits into
Open
quinnj-bot[bot] wants to merge 2 commits into
quinnj-bot[bot] wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The hasfield guard for (; x=p) named the input temp directly in its source without listing it in the guard's assignments. simplify therefore dropped the fetch that computes a nested input when nothing else used it, and (; a=(; b=_)) threw UndefVarError on every input. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #138 +/- ##
=======================================
Coverage 99.38% 99.38%
=======================================
Files 12 12
Lines 1132 1133 +1
=======================================
+ Hits 1125 1126 +1
Misses 7 7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Why
The README documents
(;x=p)as "matches values with fieldxmatching patternp", and patterns nest. A named-field pattern nested inside another threwUndefVarErroron every input when the inner pattern used none of the inner value's fields:The same happens with an unused binding (
(; a=(; b)) => 1), in@ismatch, and in@match pattern = value.What changed
A named-field pattern first checks
hasfield(typeof(input), :x). That check named theinputtemporary in its source but did not list it among the expression's inputs (itsassignments).simplify, which removes fetches whose results are unused, therefore dropped the fetch of the nested value, and the check read a temporary that was never assigned. The check now listsinput, so the fetch is kept. The decision automaton for the example above gains the missingFETCH «input_value.a»node.No issue was filed. I found this with a differential test harness for
@match(a small reference interpreter written from the README, compared on random patterns and values).Verification
UndefVarErroronmainand pass with the fix.Pkg.test()on Julia 1.12.6: 1060 passed, 5 broken (main: 1057 passed, the same 5 broken).libopenlibm.so: cannot enable executable stack). PR Fix @match on 32-bit Julia (hash seeds typed as UInt64) #134 shows the same failure; this PR does not touch CI.Review notes
inputor listed inassignments.hasfieldchecks on the same value are still shared between cases, and the existing node-count tests are unchanged.🤖 Generated with Claude Code