feat(t27b): drop top-level statements like the reference (StmtExpr, +5 counted) - #6365
Merged
Merged
Conversation
t27c's Zig backend emits nothing for a top-level statement (gen_decl), so the reference compiles files whose dotted `module a.b;` / `use a.b;` the parser reads as `a` plus a stray `.b`. t27b now drops a top-level StmtExpr the same way and leaves it out of the analyzed-fn roots. Corpus (specs, --reference t27c): counted 648/720 -> 653/720, checked pass 370 -> 373, mismatch 0 -> 0. Closes #6363 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
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.
Closes #6363
Refs #6063
What
t27c's Zig backend (
gen_declinbootstrap/src/compiler.rs) emits nothing for a statement at top level, so the reference compiles a file that has one. t27b refused every such file withStmtExpr("statement at top level" / "stray.bat top level"). It now drops a top-levelStmtExprthe same way, and leaves it out of the roots of the analyzed-fn set (a fn named only there is never emitted-and-analyzed by the reference either).Sources of the shape in the corpus: a dotted
module a.b;/use a.b;read by the t27c parser asaplus a stray.b(#6102), and the tail of a test body the parser closed early. Top-levelStmtAssignis a separate family and stays refused.Numbers (my runs,
t27b corpus specs --timeout-ms 60000 --jobs 8 --blockers --reference /tmp/t27shared/release/t27c, from master bd59d8c)Newly passing:
specs/sandbox/health.t27,specs/sandbox/https_enforce.t27,specs/port/trinity/src/tri/gen_arithmetic.t27(pass, with tests);specs/lsp/language.t27,specs/sandbox/modules.t27(pass_vacuous).Still blocked by other families after this (reference passes):
wrapup-auto(StmtAssign, ExprArrayLiteral),ternary_vs_binaryandorphan_detection(ExprArrayLiteral),gen_image(std.mem.Allocator),gen_work_stealing(anonymous struct). The remainingStmtExpr statementblocker (value statement in a body, 1 reference-passing file) is a different construct.Tests
top_level_statements_are_dropped_like_the_referenceincli/t27b/tests/source.rs: dotted module/use, a failing top-levelassert, a top-level call to a fn whosetryis now not refused, and the negative control (the sametryin a fn a test reaches is still refused). Each source was checked againstt27c test-report(all pass).cargo test -p t27bgreen.Reference note
The reference silently discarding top-level statements (including a failing
assert(1 == 2);) is t27c behaviour, matched here, not endorsed; the dotted-name parse is #6102.🤖 Generated with Claude Code