← Back to Pull requests

fix: reject trailing top-level input #1986

Open
unknown opened this pull request with 310 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 04, 2026 04:55 UTC
Author

Fixes #1895.

Problem

parseTopLevelOp returned after the first successfully parsed top-level
operation without checking that the input had been consumed. Any suffix was
silently discarded: veir-opt exited 0 and printed only the first operation.
With --split-input-file this is easy to hit, because a mistyped chunk marker
silently drops a test case.

Change

After the existing alias parsing, operation parsing, and unresolved
forward-value validation, parseTopLevelOp now requires the current token to be
.eof and otherwise reports a positioned error:

<file>:<line>:<column>: error: unexpected trailing input after top-level operation

No new lexer, re-parse, or builtin.module special case was added; the check
uses the existing parser monad (peekToken, throwAtCurrentPos).

Tests

  • UnitTest/MlirParser.lean: direct parseTopLevelOp regression asserting the

  • rejection of a second top-level operation.
  • Test/Tools/trailing-input.mlir: command-level regression asserting the

  • nonzero exit and the positioned diagnostic at the second operation.
  • Test/Tools/split-markers.mlir: its no-split run deliberately passes two

  • top-level modules and previously asserted the old silent-success behaviour;
    it now asserts the required rejection.

    Verification

    | Gate | Result |
    |---|---|
    | lake build --iofail | 656 jobs, success |
    | lake test --iofail | exit 0 (compile-time assertions, including the new #guard_msgs regression) |
    | uv run lit Test/Tools -v | 5/5 passed |
    | make tests (rebased on c2304a2) | 1,514 passed, 2 expected failures, 7 unsupported / 1,523 discovered; ExArray passed |
    | ./Tools/check-interpreter-cross-checks | exit 0 |
    | ./Tools/check-orphan-modules | exit 0 under Python 3.13 |
    | git diff --check | no whitespace errors |

    Baseline before the change: lake build 656/656 jobs; the unchanged binary
    accepted the two-operation reproducer with exit status 0 while printing only
    the first module.

    Manual command checks after the change:

    | Input | Result |
    |---|---|
    | two top-level builtin.module ops | exit 1, 2:1: error: unexpected trailing input after top-level operation |
    | module followed by this is garbage }}} | exit 1, positioned error |
    | single valid module | exit 0, unchanged output |
    | --split-input-file with a correct // ----- | exit 0, both chunks printed |
    | --split-input-file with a mistyped // --- | exit 1, error at the second module |

    Diff: 310 lines (+232 / -78) across 3 files Reviewer: math-fehr Review duration: 38421m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.40) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 310 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.343
    Real PR Conversation Timeline
    1 comments
    "Review active on #1986"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.3% (MEDIUM) · Higher = larger blast radius
    40.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23.0% · Safe to merge
    23.0%
    Repository