w6a/parse: write diagnostics with str .len (fix perr truncation)

perr() in parse.ww wrote the "w6a: " prefix with a hand-counted length
of 4, but the string is 5 bytes — the trailing space was dropped, so
every assembler diagnostic printed as "w6a:<file>" with no separating
space. Replace the prefix length (and the ": " / "\n" literal writes in
the same function) with the string's own .len via the local-binding
idiom, fixing the off-by-one and closing the hand-count class here. Uses
str-variable .len (correct on both stages), not "literal".len (cstage
miscompile, #14), so this is byte-identical cs==ww.

Verified: w6a_ww on a bad input now writes "w6a: <file>: <msg>\n" with
the space restored; w6c and w6c_ww emit byte-identical asm for the
regenerated main.combined.ww.
This commit is contained in:
2026-06-03 00:01:50 +09:00
parent c64c478e3f
commit dbb52e25fe
2 changed files with 12 additions and 6 deletions

View File

@@ -3299,12 +3299,15 @@ export fn intern(a: *asm_, name: str) *asym = {
};
fn perr(a: *asm_, msg: str) void = {
os.write(2, "w6a: ".ptr, 4u64);
let pfx: str = "w6a: ";
os.write(2, pfx.ptr, pfx.len: u64);
let f: str = a.file;
os.write(2, f.ptr, f.len: u64);
os.write(2, ": ".ptr, 2u64);
let sep: str = ": ";
os.write(2, sep.ptr, sep.len: u64);
os.write(2, msg.ptr, msg.len: u64);
os.write(2, "\n".ptr, 1u64);
let nl: str = "\n";
os.write(2, nl.ptr, nl.len: u64);
a.errs += 1;
};

View File

@@ -170,12 +170,15 @@ export fn intern(a: *asm_, name: str) *asym = {
};
fn perr(a: *asm_, msg: str) void = {
os.write(2, "w6a: ".ptr, 4u64);
let pfx: str = "w6a: ";
os.write(2, pfx.ptr, pfx.len: u64);
let f: str = a.file;
os.write(2, f.ptr, f.len: u64);
os.write(2, ": ".ptr, 2u64);
let sep: str = ": ";
os.write(2, sep.ptr, sep.len: u64);
os.write(2, msg.ptr, msg.len: u64);
os.write(2, "\n".ptr, 1u64);
let nl: str = "\n";
os.write(2, nl.ptr, nl.len: u64);
a.errs += 1;
};