autosetup: detect the via-ir-required family by its remediation hint - #135
Open
shellygr wants to merge 2 commits into
Open
autosetup: detect the via-ir-required family by its remediation hint#135shellygr wants to merge 2 commits into
shellygr wants to merge 2 commits into
Conversation
A diagnostic requires the IR pipeline when solc attaches the hint naming that pipeline or its flag (`--via-ir`, `viaIR: true`, "via-ir pipeline", "IR pipeline"), whatever the diagnostic itself is called. The hint is matched on whitespace-normalized text and tolerates a wrap inside a hyphenated token; the conf key `solc_via_ir` stays outside the family since it belongs to the error calling for the opposite fix. The affected file comes from the compiled unit's `Compiling <path>...` line when there is one, and otherwise from the first `-->` source location under the hint, so whole-project compiles are attributed too. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The via-ir hint is read per diagnostic, delimited by solc's own labels (Warning:/<Kind>Error:/YulException:) and the Compiling progress lines. A hint counts only inside a diagnostic that offers no alternative remedy: stack-too-deep and YulException carry the same hint while also offering the optimizer and fewer locals, and stay with stack_too_deep_via_ir and the yul rungs so their ladder is climbed in order. Attribution by `-->` source location is confined to the diagnostic that asked for via-ir, so a neighbouring diagnostic's file is never enabled. The bare `IR pipeline` spelling requires a word boundary, keeping prose in quoted source lines out of the family. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
The bug
_detect_via_ir_requiredmatched one literal solc phrasing:solc has more than one way of saying the same thing. A corpus project hit:
That phrasing was missed, so
solc_via_ir_mapstayed all-false, compilation failed, autosetupmisattributed it to imports, patched 2253 files, failed again, reverted, and reported
import-patch-failed. Nothing about imports was broken.The fix
Match the family by the remediation hint rather than the diagnostic wording — the
--via-irflag, the
viaIR: trueJSON key, or "(via-)ir pipeline" — against whitespace-normalized text, sincesolc hard-wraps at a fixed width and breaks tokens mid-word.
Two constraints make that safe:
--via-irhint toevery stack-too-deep and
YulException, where the optimizer ladder should run first. Those areexcluded, so
stack_too_deep_via_irkeeps its ladder.whole-project compile with no
Compiling <path>...line to key on, so the detector falls back tothe
-->source location — but only one belonging to the same diagnostic. An arrow from anadjacent warning names an unrelated contract.
Review
An adversarial review confirmed five defects in the first commit, all fixed in
bf68100: thestack-too-deep hijack above; an unbounded
-->scan that attributed via-ir to a neighbouringwarning's file; a missing word boundary that matched "theIR pipeline" in a source-line comment; and
two untested regex alternatives plus a missing negative test — both now pinned, with mutation
evidence that the new tests fail when each alternative is removed.
513 passed, 9 skipped; pyright clean.🤖 Generated with Claude Code