Skip to content

autosetup: detect the via-ir-required family by its remediation hint - #135

Open
shellygr wants to merge 2 commits into
masterfrom
shelly/via-ir-detect-family
Open

autosetup: detect the via-ir-required family by its remediation hint#135
shellygr wants to merge 2 commits into
masterfrom
shelly/via-ir-detect-family

Conversation

@shellygr

@shellygr shellygr commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

The bug

_detect_via_ir_required matched one literal solc phrasing:

marker = "only available using the via-ir pipeline"

solc has more than one way of saying the same thing. A corpus project hit:

UnimplementedFeatureError: Copying of type struct S memory[] memory to storage is not
supported in legacy (only supported by the IR pipeline). Hint: try compiling with
`--via-ir` (CLI) or the equivalent `viaIR: true` (Standard JSON)

That phrasing was missed, so solc_via_ir_map stayed all-false, compilation failed, autosetup
misattributed 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-ir
flag, the viaIR: true JSON key, or "(via-)ir pipeline" — against whitespace-normalized text, since
solc hard-wraps at a fixed width and breaks tokens mid-word.

Two constraints make that safe:

  • Only diagnostics that offer no other remedy. solc >= 0.8.13 appends the same --via-ir hint to
    every stack-too-deep and YulException, where the optimizer ladder should run first. Those are
    excluded, so stack_too_deep_via_ir keeps its ladder.
  • Attribution stays inside one diagnostic block. Phrasing (b) usually arrives from a
    whole-project compile with no Compiling <path>... line to key on, so the detector falls back to
    the --> source location — but only one belonging to the same diagnostic. An arrow from an
    adjacent warning names an unrelated contract.

Review

An adversarial review confirmed five defects in the first commit, all fixed in bf68100: the
stack-too-deep hijack above; an unbounded --> scan that attributed via-ir to a neighbouring
warning'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

shellygr and others added 2 commits August 8, 2026 18:01
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant