t27b: @compileAssert as assert, integer as f64 as @floatFromInt (+10 counted) - #6322
Merged
Merged
Conversation
…atFromInt
ExprCall(@compileAssert) was the only listed lab blocker on 9 specs the
reference passes (specs/numeric/gf{6,10,14,48,96,128,256,512,1024}.t27).
t27c's Zig backend lowers `@compileAssert` through the same arm as
`assert` (`if (!(cond))`; a false one fails the compile inside an
invariant's comptime block and is a runtime check inside a test), so
t27b now does the same, with the same string-literal message rule.
The 9 files then stopped at `EXP_BITS as f64`. The reference emits
`@as(f64, @floatFromInt(x))` for an integer operand, so an integer
`as f64` now lowers as @floatFromInt with result type f64. Float or
bool `as f64` and f64 `as` an integer stay refused as ExprCast(f64).
t27b corpus specs --reference (t27c built from 65e6ddb): checked
passes among the 720 reference passes 307 -> 317 (the 9 gf files and
specs/queen/task_analysis.t27), mismatch 0, no new pass where the
reference fails.
Closes #6319
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
This was referenced Oct 5, 2026
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 #6319
Refs #6063
What
@compileAssert(cond[, "msg"])lowers through the same arm asassertincli/t27b/src/lower.rs. The reason: t27c's Zig backend does exactly that (node.name == "@compileAssert" || node.name == "assert"inbootstrap/src/compiler.rs). It emitsif (!(cond)) <fail>. Inside aninvariant(acomptimeblock) a false condition fails the compile. Inside atestit is a runtime check.x as f64with an integerxlowers as@floatFromIntwith result type f64. The reference emits@as(f64, @floatFromInt(x))for it (is_float_exprfalse). A float or bool operand, and f64asan integer, stay refused asExprCast(f64).The lab (0851055) listed
ExprCall(@compileAssert)as the only blocker on 9 specs the reference passes. That list was incomplete. With@compileAssertlowered, all 9 stopped next atEXP_BITS as f64, so this PR also covers that second blocker.Verdicts vs the reference (mutation control)
@compileAssertin invariant / test@compileAssertin a test@compileAssertin an invariant (int and f64 operands, mutated gf10)error: assertion failed(comptime)Neither path passes a file with a false invariant. The failure class is different, though: the reference fails to compile, t27b fails at run time.
assertin an invariant already behaves this way in t27b. Fixing it would need a "does not compile" outcome in t27b, which is out of this PR's scope.Corpus (
t27b corpus specs --blockers --reference <t27c built from 65e6ddba3>, local, load 7-36)Counted gain: +10. The 9
specs/numeric/gf{6,10,14,48,96,128,256,512,1024}.t27(4-6 invariants each, now run) plusspecs/queen/task_analysis.t27(priority as f64). All 10 are reference-pass and t27bpass. JIT and interpreter agree.Reference-backed greedy top 5 after:
ConstDecl(str field)+5,ExprLiteral(char literal)+4,ExprIf+5,StmtExpr+4,ExprArrayLiteral+4.Tests
compile_assert_is_assert(cli/t27b/tests/source.rs) covers true and false, invariant and test, f64 operands from integer casts, and the message rule. Its source was also run throught27c test-report. With the broken invariant it is BLOCKED; without it, 1 of 2 tests fail. Both match.f64_refusals_name_the_constructnow refusesx as f64(f64 operand),x as i32and(n > 0) as f64by name.cargo test -p t27b: all green.🤖 Generated with Claude Code