Tagged path rejects alias mapping keys and drops key anchors #12

Closed
opened 2026-07-12 12:25:32 +00:00 by Mihaela · 0 comments
Mihaela commented 2026-07-12 12:25:32 +00:00 (Migrated from codeberg.org)

Status (2026-07-12)

Open. Disclosed as a known limit while closing #9: the anchors/aliases/styles
round-trip work preserves alias structure in VALUE positions, but a document
using an alias where a mapping key is expected (*b : value, yaml-test-suite
E76Z/26DV) still fails to parse on the Tagged path with expectedScalarKey.
This is pre-existing behavior, not a regression: Tagged.EventComposer's
composeMappingKey accepts only scalar events. The plain parse(_:) path
handles alias keys correctly (see AliasAsMappingKeyTests), so this is a
Tagged-path capability gap only.

Related: an anchored scalar KEY's anchor is registered for later alias
resolution but is not carried on the pair itself, so it does not re-emit
(Tagged.Pair.key is a String, not a node). Same root cause, same fix
surface.

Impact

parseTagged(_:) rejects documents the primary parser accepts whenever an
alias stands in key position, and a round trip through Tagged.Dumper loses
anchors that sit on keys. The corpus round-trip law in
TaggedNodeCorpusRoundTripTests counts these documents as "rejected", so the
gap is visible, not silent.

Work

  • Widen Tagged.Pair's key from String to a node-carrying representation
    (a Tagged.Node or a scalar-plus-properties key type). This is a breaking
    change to Tagged.Pair, Tagged.Mapping's subscript, Tagged.Constructor
    key handling, and the validator's key-uniqueness check, so it should land
    as its own pass, not ride along on another change.
  • Teach composeMappingKey to accept alias events (resolving through the
    anchors table like composeNode does) and to carry key anchors.
  • Extend Tagged.Dumper.renderBlockPair/renderInline to emit key
    properties and alias keys (*a : value).
  • Extend the corpus round-trip law: E76Z/26DV-shaped fixtures move from
    "rejected" to round-tripping with alias-key topology intact.

Part of #8.

## Status (2026-07-12) Open. Disclosed as a known limit while closing #9: the anchors/aliases/styles round-trip work preserves alias structure in VALUE positions, but a document using an alias where a mapping key is expected (`*b : value`, yaml-test-suite E76Z/26DV) still fails to parse on the `Tagged` path with `expectedScalarKey`. This is pre-existing behavior, not a regression: `Tagged.EventComposer`'s `composeMappingKey` accepts only scalar events. The plain `parse(_:)` path handles alias keys correctly (see `AliasAsMappingKeyTests`), so this is a `Tagged`-path capability gap only. Related: an anchored scalar KEY's anchor is registered for later alias resolution but is not carried on the pair itself, so it does not re-emit (`Tagged.Pair.key` is a `String`, not a node). Same root cause, same fix surface. ## Impact `parseTagged(_:)` rejects documents the primary parser accepts whenever an alias stands in key position, and a round trip through `Tagged.Dumper` loses anchors that sit on keys. The corpus round-trip law in `TaggedNodeCorpusRoundTripTests` counts these documents as "rejected", so the gap is visible, not silent. ## Work - Widen `Tagged.Pair`'s key from `String` to a node-carrying representation (a `Tagged.Node` or a scalar-plus-properties key type). This is a breaking change to `Tagged.Pair`, `Tagged.Mapping`'s subscript, `Tagged.Constructor` key handling, and the validator's key-uniqueness check, so it should land as its own pass, not ride along on another change. - Teach `composeMappingKey` to accept alias events (resolving through the anchors table like `composeNode` does) and to carry key anchors. - Extend `Tagged.Dumper.renderBlockPair`/`renderInline` to emit key properties and alias keys (`*a : value`). - Extend the corpus round-trip law: E76Z/26DV-shaped fixtures move from "rejected" to round-tripping with alias-key topology intact. Part of #8.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: NodetteHQ/PureYAML#12
No description provided.