yaml: fix 5 flow-context over-accepts/under-accepts (#31561)
## What
Five spec-conformance fixes in flow context (`{…}` / `[…]`), each
previously a `test.todo` from the #31203 review catalog:
| Input | Before | After | Spec |
|---|---|---|---|
| `{a: "b":1}`, `{a: 1 b: 2}` | accepted as garbage | error | [140]
entry must be followed by `,` or `}` |
| `{a: b: c}`, `{? a: b: c}` | nested `{a:{b:c}}` | error | [147] value
is `ns-flow-node`, not a pair |
| `["a":\nb]`, `[a: \nb]` | error | `[{a:"b"}]` | [149]/[80]
`s-separate(n,FLOW-IN)` spans lines |
| `{[1]\n:2}`, `{{k:1}\n:2}` | error (but `{"a"\n:1}` accepted) | accept
| [148] JSON-key + `:` separation spans lines in flow |
| `[? &x :b]`, `{? !!str :b}` | `[{null:"b"}]` | `[{":b":null}]` | [126]
`:b` after `?`+property is `ns-plain-first` |
## How
- `parse_flow_mapping`: after the value parse, only `,`/`}` is valid
(was unconditional `continue`). Value parse threads
`current_mapping_indent` so the cmi check returns the bare scalar
instead of consuming `: …`.
- `parse_block_mapping` reached from flow: skip the `block_indents.push`
(the key's column is not a block boundary). `parse_block_indented` skips
its [196] `belongs_to_parent` indent dispatch in flow context.
- `parse_node` Alias/SequenceStart/MappingStart arms: order the
`FlowKey` early-return *before* the `MultilineImplicitKey` check,
matching the Scalar arm.
- `parse_flow_explicit_key`: own the property loop in flow-in (so the
post-property re-scan tokenizes `:b` as plain), then wrap only the
content parse in `FlowKey`.
## Tests
5 todos flipped to passing tests; 2029 pass / 0 fail / 402/402
yaml-test-suite / 1015/1015 4-parser consensus.
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> D
Dylan Conway committed
9d000561c937b8e00569519ba1c7973e4b967fb5
Parent: 57d8e38
Committed by GitHub <noreply@github.com>
on 5/29/2026, 8:05:54 AM