Repository navigation
A comptime string value re-emitted as a literal carries the raw marker (#1246) - #1255
Merged
Merged
Conversation
#1246) `const C: str = r#"a\"b\n"#` printed `a"b` and a newline. `const` desugars to a comptime-wrapped let; the evaluator decodes the literal once (comptime_decode_string_escapes honors the parser's `\x01raw\x01` marker and returns the bytes as written), then ComptimeTransform re-emitted the CV_STR value as a fresh NK_STRING_LIT interned WITHOUT the marker, so codegen's decoder processed the already-decoded `\"` and `\n` a second time. Same at ct_build_string_lit (derived display/variant-name literals). Both re-emission sites now go through ct_raw_literal_text: a literal the transform emits holds decoded bytes and says so. Found when switching the embedded stdlib generators to `const` broke every `use std.build` program (#1247); behav_const_raw_string_keeps_escapes pins const/let/plain-const byte for byte.
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.
Fixes #1246.
const C: str = r#"a\"b\n"#printeda"band a newline.constdesugars to a comptime-wrapped let; the evaluator decodes the literal once (comptime_decode_string_escapeshonors the parser's\x01raw\x01marker and returns the bytes as written), thenComptimeTransformre-emitted theCV_STRvalue as a freshNK_STRING_LITinterned without the marker, so codegen's decoder processed the already-decoded\"and\na second time. Same atct_build_string_lit(derived display/variant-name literals).Both re-emission sites go through
ct_raw_literal_text: a literal the transform emits holds decoded bytes and says so. Found when switching the embedded stdlib generators toconstbroke everyuse std.buildprogram (#1247).behav_const_raw_string_keeps_escapespins const/let/plain-const byte for byte.Battery (seed-driven, worktree): build, :fixpoint, :test, :test-green, :last-green all rc=0.