diag: don't fire prefix-precedence hint inside parens#309
Merged
Conversation
The same-precedence prefix-pair trap hint (`*/`, `/*`, `+-`, `-+`) added in #301 fires on the parenthesised form too, e.g. `(/ *errs 100 tot)`. That's the recommended disambiguation shape, so flagging it contradicts the hint's own advice and spams every rate-calc program on every run. Suppress when the immediate predecessor of op1 is `LParen`. Token-local, covers nested parens (`((*/ a b c))`) because the immediate predecessor is still `LParen`. Bare unparenthesised form continues to fire.
`(/ *errs 100 tot)` is the canonical rate-calc shape and now emits no hint. Engine harness picks it up via the `-- run:` / `-- out:` assertion as a higher-level regression test.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
danieljohnmorris
added a commit
that referenced
this pull request
May 16, 2026
twelve fixes since 0.11.3, surfaced by rerun4 personas plus standing asks: srt-Cranelift TLS desync (#306), CLI auto-run restoration (#307), OP_LISTAPPEND O(n^2) JIT memory regression (#308), precedence-pair hint false-positive on parens (#309), prefix ?? accepts call expression (#310), += pure-shape docs (#311), bare-mutation silent no-op verifier warning ILO-T033 (#312), asin/acos/atan inverse trig builtins (#313), flat cross-engine (#314), cond{~v} discard hint multi-stmt false-positive (#315), rsrt fn xs key-fn overloads (#316), xs.(expr) paren-after-dot diagnostic hint (#317).
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
PR #301's same-precedence prefix-pair trap hint (
*/,/*,+-,-+) fires on the parenthesised form too, e.g.(/ *errs 100 tot). That's the recommended disambiguation shape, so flagging it contradicts the hint's own advice and spams every rate-calc program on every run. Streaming-tail rerun4 surfaced this as a false-positive papercut.Repro
Before:
After:
Bare unparenthesised form still fires as before.
What's in the diff
diag: suppress prefix-precedence hint inside explicit parens— indetect_prefix_precedence_trap(src/main.rs), skip when the immediate predecessor ofop1isLParen. Token-local, one extra guard. Covers nested parens (((*/ a b c))) because the immediate predecessor is stillLParen. Adds four unit + integration tests: paren-grouped pair (all four shapes), nested parens, bare form still fires, unit-level detector pin.example: parenthesised prefix pair runs silent—examples/prefix-pair-in-parens.iloexercises the rate-calc shape under the engine harness via-- run:/-- out:assertions.Test plan
cargo build --release --features craneliftcargo test --release --features cranelift— full suite, 0 failurescargo clippy --release --features cranelift --all-targets -- -D warnings— cleancargo fmt --check— clean(/ *errs 100 tot)silent, bare*/a b cstill emits the hint*/,/*,+-,-+) suppressed inside parens((*/ a b c))suppressed