Repository navigation
feat(t27b): lower optionals -- ?T, null, .?, == null - #6357
Merged
Merged
Conversation
?T lives in memory: the payload, then a has-value byte. Locals, params,
sret returns and struct fields take it; `.?` traps as TrapKind::Null
("attempt to use null value"), as Zig does. `if (x) |v|` is refused as
StmtIf(capture): t27c gen drops the capture and Zig fails.
Corpus: counted 634 -> 648 of 720, checked pass 356 -> 370, mismatch 0.
Closes #6356
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 #6356
Refs #6063
What
?Tincli/t27b/src/lower.rs(LTy::Opt): an in-memory aggregate, payload at offset 0 then a has-value byte, rounded to the payload alignment. Locals, params (by pointer), returns (sret), struct fields.null(where an optional is wanted),x == null/x != null,?T == Tagainst a constant or variable, andx.?(alsox.?.len,&x.?,x.? = v).x.?on null traps with the newTrapKind::Null= 11, "attempt to use null value", as Zig does.StmtIf(capture)(t27c gen drops|v|, so Zig reports an undeclared identifier: no reference to match),ExprBinary(?T)(two optionals compared),ExprFieldAccess(?T)(field of an optional without.?),ConstDecl(?T)(module-level optional).optionals_match_the_referenceandoptionals_the_reference_does_not_match_are_refusedincli/t27b/tests/source.rs. Verdicts were checked undert27c test-report(6 PASS, 2 FAIL; the capture case is BLOCKED).Corpus
t27b corpus specs --blockers --reference t27c --reference-cache <own cache>, fixed binary copies, before = origin/master d8375ad.The +1 fail is
specs/port/scripts/check-first-party-doc-language.t27. The reference also fails it, on the same test:find_last_char_foundFAIL, the other 3 PASS. It is outside the 720.Top of the greedy order after: StmtExpr +5, ExprArrayLiteral +5, type undefined +4, ExprCall(std.*) +4, type f32 +3.
🤖 Generated with Claude Code