Repository navigation
feat(t27b): str as []const u8 -- literals, .len, ==/!= (75 files pass, 0 mismatch) - #6229
Merged
Merged
Conversation
str, &str, string and []const u8 lower to Zig's []const u8: a 16-byte (ptr, len) aggregate passed by address, returned through sret and copied like a struct. String literals are compile-time values whose bytes sit in read-only data. .len reads the length; == and != compare contents like std.mem.eql (two literals fold, otherwise one synthesized IR helper, __t27b_str_eql). t27b corpus specs: 70 -> 99 files pass (223 -> 555 tests), 0 mismatch. The 29 new files also pass the reference path (t27c gen + zig test). Refs #6063 Closes #6183 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts: lower.rs (peek_string beside the new cast(); cast() rejects a string), blockers.rs fixture (ExprCast(to bool) and a char literal). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #6183 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 #6183
Refs #6063
What
t27b lowers
str,&str,stringand[]const u8as Zig's[]const u8: a 16-byte (ptr, len) aggregate (ptr @0, len u64 @8, align 8) that is handled like a struct. It is passed by address, returned through sret, and copied on assignment.Val::S). Their bytes, plus a trailing NUL, are deduplicated in read-only data. Astrplace is only materialized where one is needed..lenfolds for literals and string constants. Otherwise it reads the u64 at offset 8.==/!=compare contents likestd.mem.eql. Two literals fold. Anything else calls one synthesized IR function,__t27b_str_eql, which compares the lengths and then loops over the bytes. It is only emitted when used.strconsts must be string literals. Anything else is rejected with a precise reason.s[i], slicing,.ptr(ExprFieldAccess(str)), ordering and arithmetic on strings (ExprBinary(op)"on a string"), andstrfields in module-level struct constants (ConstDecl(str field)).Unit tests in
cli/t27b/tests/source.rs:strings_literals_params_fields_and_equality: params, struct fields, sret returns, equality, and a failing-assert trap line.string_rejections_are_precise: 7 cases.The
blockers.rsfixture now uses a char literal, because string literals are no longer a blocker.Corpus (
t27b corpus specs, 1212 files, both binaries built from master 0011bb0 vs this branch)fpga/verification/build_verify.t27, pre-existing)type stris no longer a first blocker.t27c gen+zig test): 29/29 compile, every test passes.--referencerun shows reference 675 pass.Ratchet ledger: not blessed here
tri t27b ratchet --run <branch run>reports the 29 newly passing files as UNEXPECTED PASS. That is the expected signal for this change.I did not bless
docs/reports/t27b_expectations.jsonin this PR, because the same run also reports findings that already exist on master and are unrelated to strings:specs/crons/mac-trios-*and othersqueen-rehearsal.t27A bless here would fold those findings in. A steward re-bless after merge (
tri t27b ratchet --blessfrom a lab run, as for #6188) records the 29 files as pass.Environment
CARGO_BUILD_JOBS=4 --target-dir /tmp/memory-target.🤖 Generated with Claude Code