fix(verify): diagnostic for x=+x 1 mutation pattern in @ loops (ILO-450)#750
Merged
Conversation
Collaborator
Author
|
mini pc is reviewing this |
Reapplies the loop-rebind diagnostic from the original PR #750 on top of current main. Renumbered T047 → T048 because main already uses T047 for two earlier-merged diagnostics (silent brace-fallthrough and sum-variant constructors in list literals). `x = +x 1` inside `@x xs` is the canonical wrong-output footgun: the loop engine resets the iterator from its cursor each iteration, so the rebind is silently discarded. The verifier now warns at the innermost loop binding only; outer-var rebinds inside an inner loop are fine. Adds 5 unit tests covering foreach + range + nested + non-iterator rebinds + accumulator pattern. Registry entry documents the canonical fixes (accumulator name, fld). Closes ILO-450. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0788fab to
35ac265
Compare
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
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.
Summary
ILO-T047warning when aStmt::Letinside a@bindingloop rebinds the loop's own iterator variable (e.g.x=+x 1inside@x xsor@x 0..10)acc=0;@x ...{acc=+acc x}) orfoldTest plan
loop_var_rebind_foreach_warns— fires on@x xs{x=+x 1}loop_var_rebind_forrange_warns— fires on@i 0..10{i=+i 1}loop_var_rebind_other_binding_no_warn— accumulator patternacc=+acc xis cleanloop_var_rebind_nested_inner_warns— inner loop var warned, not outerloop_var_rebind_outer_in_nested_no_warn— outer var rebind inside inner loop not flaggedCloses ILO-450
🤖 Generated with Claude Code