Follow-up to #708. After 91fc0f716 (explicit indicator) and 81ae379c8 (chomping), js/bun/yaml/yaml-block-scalar-matrix.test.ts is 941 pass / 143 fail — up from 598 at the start of the session. Pinned Bun is 1084 / 0, so the remaining 143 are real gaps.
Remaining failures by group
| group | ~count | what the group covers |
|---|---|---|
ws | 66 | whitespace-only and leading-whitespace content |
empties | 33 | trailing/interior empty lines |
fold | 30 | folded (>) line joining |
adv | 8 | unicode / BOM in content |
tab | 3 | tabs after the content indent |
crlf | 3 | CRLF line endings |
Representative failure — ws/>2+/only2/w4:
input "- >2+\n \n \n"
expected [" \n \n"]
received [""]The structural divergence
Phase 1 now matches Bun. Phase 2 does not.
Bun (~/Code/bun/src/parsers/yaml.rs, phase-2 0x20 arm) consumes at most content_indent spaces and then hands the next character to the normal content path:
let mut indent = Indent::from(0);
while indent.is_less_than(ctx.content_indent) && next == 0x20 {
indent.inc(1); self.inc(1);
}
self.line_indent = indent;
let nc = next;
ctx.cur_more_indented = matches!(nc, 0x20 | 0x09);
__c = nc;
break;Home (packages/runtime/src/parsers/yaml.zig:2939-2974) consumes the entire space run, and appends everything past content_indent to the text inline, duplicating the folding logic:
var indent: Indent = .from(0);
while (self.next() == ' ') {
indent.inc(1);
if (ctx.content_indent.isLessThan(indent)) {
switch (folded) { ... append ' ' with leading_newlines handling ... }
}
self.inc(1);
}Two different algorithms. Home's passes 941 cases, so it is not simply wrong — but it has no counterpart in Bun's live code, and the classes it gets wrong (whitespace-only lines, folded joining, interior empties) are exactly the ones where "append the overflow immediately" differs from "stop at the indent and let append decide".
Bun also carries two ctx fields Home lacks that this arm sets: cur_more_indented and prev_more_indented (yaml.rs:4897 — "space/tab beyond content_indent? Breaks adjacent to such lines"). Those drive folding decisions, which is likely why the fold group is a distinct cluster.
Suggested approach
Replace Home's phase-2 space arm with Bun's shape rather than patching cases:
- Add
cur_more_indented/prev_more_indentedtoLiteralScalarCtx. - Make the space arm stop at
content_indent, setline_indent, setcur_more_indented, and fall through to the content path. - Move the overflow-space handling out of the scan loop into
append, where Bun does it.
This is intricate control flow and worth adversarial review before landing — a partial port here is how the CSS nesting budget in #705 ended up relocating an abort rather than fixing it.
Refs #66