fix: reject trailing top-level input #1986
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
math-fehr
Fixes #1895.
Problem
parseTopLevelOpreturned after the first successfully parsed top-leveloperation without checking that the input had been consumed. Any suffix was
silently discarded:
veir-optexited0and printed only the first operation.With
--split-input-filethis is easy to hit, because a mistyped chunk markersilently drops a test case.
Change
After the existing alias parsing, operation parsing, and unresolved
forward-value validation,
parseTopLevelOpnow requires the current token to be.eofand otherwise reports a positioned error:No new lexer, re-parse, or
builtin.modulespecial case was added; the checkuses the existing parser monad (
peekToken,throwAtCurrentPos).Tests
UnitTest/MlirParser.lean: directparseTopLevelOpregression asserting therejection of a second top-level operation.
Test/Tools/trailing-input.mlir: command-level regression asserting thenonzero exit and the positioned diagnostic at the second operation.
Test/Tools/split-markers.mlir: its no-split run deliberately passes twotop-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| exit0(compile-time assertions, including the new#guard_msgsregression) ||
uv run lit Test/Tools -v| 5/5 passed ||
make tests(rebased onc2304a2) | 1,514 passed, 2 expected failures, 7 unsupported / 1,523 discovered; ExArray passed ||
./Tools/check-interpreter-cross-checks| exit0||
./Tools/check-orphan-modules| exit0under Python 3.13 ||
git diff --check| no whitespace errors |Baseline before the change:
lake build656/656 jobs; the unchanged binaryaccepted the two-operation reproducer with exit status
0while printing onlythe first module.
Manual command checks after the change:
| Input | Result |
|---|---|
| two top-level
builtin.moduleops | exit1,2:1: error: unexpected trailing input after top-level operation|| module followed by
this is garbage }}}| exit1, positioned error || single valid module | exit
0, unchanged output ||
--split-input-filewith a correct// -----| exit0, both chunks printed ||
--split-input-filewith a mistyped// ---| exit1, error at the second module |