Seven correctness fixes to the recently landed anchors/styles, canonical, timestamp/binary, and full-node-key work, each reproduced and covered by a regression test. - Stream dump doubled the `---` marker under explicitDocumentStart or canonical: the single-document body now renders marker-free and the stream path owns marker emission, so a two-document stream reparses as two documents, not four. - Tagged flow-mapping keys used block-context safety, so a key like `a,b` emitted bare and reparsed as several entries; flow keys now use the flow-aware plain-scalar check. - Plain scalars ending in `:` reparse as an empty-valued mapping key, so both the model and tagged emit paths now fall back to quoting them. - An alias mapping key pointing at a defined non-scalar anchor raised the misleading undefinedAlias; it now raises expectedScalarKey, and a truly undefined alias key still raises undefinedAlias. - Tagged duplicate-key detection keyed on source spelling: it now keys on the resolved scalar value plus effective tag, so 0x1 and 1 collide while 1 and "1" do not and custom-tagged keys stay distinct. - Dumping a tree nested past the emitter limit overflowed the stack. - Timestamp now accepts a leap-second value of 60, counted as 60 elapsed seconds in the epoch math. - Tagged.Dumper honors sortKeys in its block and canonical paths for all-plain-string-key mappings, matching the model dumper. Nesting-guard design: dump is public and non-throwing across 90+ call sites, so making it throwing would be a breaking change. A tree nested deeper than the parser's own maxNestingDepth cannot round-trip through PureYAML (the parser rejects it), so no faithful emission exists. Each dump entry point now measures depth iteratively (no recursion, so the guard itself cannot overflow) and, past the limit, returns a documented, reparseable marker document that resolves to null. Under the limit the existing recursive renderers run byte-identically, so parsed trees and every realistic hand-built tree are unaffected. This mirrors the parser's enforceNestingLimit, which bounds depth before any recursive consumer.
13 lines
595 B
Swift
13 lines
595 B
Swift
extension PureYAML.Tagged {
|
|
/// Key identity for duplicate detection: the resolved scalar value plus the
|
|
/// key's effective tag (its carried tag, or the implicit tag of the resolved
|
|
/// value). Two keys are the same key iff both match. Using the resolved value
|
|
/// rather than the source spelling makes `0x1` and `1` (both `int(1)`)
|
|
/// collide while `1` (`int`) and `"1"` (`str`) do not, and keeps
|
|
/// custom-tagged keys (`!foo 1` vs `!bar 1`) distinct.
|
|
struct MappingKeyIdentity: Hashable {
|
|
var value: PureYAML.Model.Value
|
|
var tag: String?
|
|
}
|
|
}
|