feat(t27b): undefined; stub in a fn the reference never analyzes - #6309
Merged
Merged
Conversation
t27c's Zig backend emits `undefined;` as is, and Zig rejects it only in a fn its lazy analysis reaches; under `zig test` neither `pub` nor `main` is a root. t27b now computes, by name, the fns a test, invariant, bench or module-level declaration can reach (an over-approximation), lowers `undefined;` outside them to a trap no test can hit (TrapKind::Stub), and refuses it inside them as ExprIdentifier(undefined) statement, where the reference does not compile either. t27b corpus specs at master 0851055: pass 277 -> 296, rejected 652 -> 633, mismatch 0. All 19 newly passing files agree test for test with t27c test-report from the same master. Closes #6308 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
6 tasks
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 #6308
Refs #6063
What
t27b corpus specs --blockersat master 0851055 rankedExprIdentifier statementfirst in the greedy order (+19 files). Its dominant shape isundefined;as a statement, the body stub a port leaves where plumbing was.What the reference does: t27c's Zig backend emits
undefined;unchanged. Zig rejects it ("value of type '@typeof(undefined)' ignored") only in a fn its lazy analysis reaches. Underzig test, neitherpubnormainis a root, so a stub that nothing analyzed names never stops the file, and every test runs.What t27b does now:
analyzed_fnscomputes the fns that a test, an invariant (emitted as acomptimeblock), a bench or a module-level declaration can reach by name, followed to a fixed point. It over-approximates: any name in a reached body counts.undefined;lowers to a trap (TrapKind::Stub) that no test can hit.ExprIdentifier(undefined) statement. The reference reports BLOCKED (does not compile) there too. Checked on scratch specs and on 3 corpus files:link_relay.t27andread_user1.t27fail on this error, andmigrate.t27on an earlier one.Left under the old name
ExprIdentifier statement(different shapes, not this PR): Rust-style tail expressions (fn f(v: u8) -> u32 { v }; 17 files, e.g. bigint, radix_economy, rust_tail_returns) andgiven/whenprose.Corpus (
t27b corpus specs, local, master 0851055, load ~10)Every one of the 19 newly passing files agrees test for test with
t27c test-report, built from the same master. All tests pass in both, with the same counts: retry 5, bulk-create-notebooks 5, gen_w365 3, gen_w388_lean 11, gen_w391_lean 13, gen_w631 6, print_pellis_seal_decimal 4, run_v51_multiple 1, verify_precision 7, check_fix_carries_source 6, run_conformance_vvp 6, railway_null_startcmd 8, ad9361_config 5, roster 3, stash 4, trios-golden-float/build 6, trios-hdc/build 1, SR-02/lib 2, trios-physics/build 4.Top first-rejection blockers after: type f32 (71), type ?T (52), type std.mem.Allocator (45), type (undeclared) (39), type [N]T (39). Greedy order after: FnDecl +15, ExprBinary statement +12, ExprCall(@compileAssert) +9.
Tests
undefined_stub_only_where_zig_never_looksincli/t27b/tests/source.rs:mainstill run both tests: one passes and one fails, the same ast27c test-report(1/2).cargo test -p t27b: all suites green.The ratchet ledger
docs/reports/t27b_expectations.jsonis not touched here. It is blessed from a lab run on master.🤖 Generated with Claude Code