Mapping key presentation style does not round-trip on the Tagged path #13

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

Status (2026-07-12)

Open. Disclosed as a known limit while closing #9: per-node presentation
styles now survive parse and dump for every VALUE node (Tagged.Scalar,
Tagged.Sequence, Tagged.Mapping all carry style), but a mapping KEY's
scalar style is not carried anywhere. Tagged.Pair holds the key as a bare
String plus keyTag; the key's source style (quoted vs plain) is read
during composition and discarded.

Impact

A document whose keys are deliberately quoted ("on": true to defeat the
YAML 1.1 boolean resolution of on, or keys with spaces) re-emits through
Tagged.Dumper with the emitter's own escapeKey policy instead of the
source's quoting choice. The VALUE is never wrong (escapeKey quotes whatever
needs quoting), so this is a fidelity gap, not a correctness bug: byte-level
key presentation does not round-trip.

Work

  • Depends on #12's key widening: once Tagged.Pair carries a key node
    rather than a String, the style field arrives for free with it, and the
    dumper's pair rendering can honor it the same way renderScalarValue
    already honors value styles.
  • Add key-style cases to the corpus round-trip law's scalar comparison once
    carried, so quoted-key fixtures gate the behavior.

Part of #8. Blocked by #12.

## Status (2026-07-12) Open. Disclosed as a known limit while closing #9: per-node presentation styles now survive parse and dump for every VALUE node (`Tagged.Scalar`, `Tagged.Sequence`, `Tagged.Mapping` all carry `style`), but a mapping KEY's scalar style is not carried anywhere. `Tagged.Pair` holds the key as a bare `String` plus `keyTag`; the key's source style (quoted vs plain) is read during composition and discarded. ## Impact A document whose keys are deliberately quoted (`"on": true` to defeat the YAML 1.1 boolean resolution of `on`, or keys with spaces) re-emits through `Tagged.Dumper` with the emitter's own `escapeKey` policy instead of the source's quoting choice. The VALUE is never wrong (escapeKey quotes whatever needs quoting), so this is a fidelity gap, not a correctness bug: byte-level key presentation does not round-trip. ## Work - Depends on #12's key widening: once `Tagged.Pair` carries a key node rather than a `String`, the style field arrives for free with it, and the dumper's pair rendering can honor it the same way `renderScalarValue` already honors value styles. - Add key-style cases to the corpus round-trip law's scalar comparison once carried, so quoted-key fixtures gate the behavior. Part of #8. Blocked by #12.
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#13
No description provided.