Repository navigation
Resolve YAML << merge keys when decoding - #217
Merged
Merged
Conversation
YAML.decode kept a `<<` merge key as a literal "<<" entry, so `web: {<<: *base,
port: 1}` failed to decode into a record or map (`["web"]["<<"]: expected int,
got object`). Merge keys now follow the YAML merge-key spec: the value is a
mapping or a sequence of them, the mapping's own keys win wherever they
appear, and earlier mappings in a sequence win over later ones. A quoted "<<"
stays an ordinary key, and a non-mapping merge value is an error.
Signed-off-by: Alex Suraci <[email protected]>
yaml.v3 resolves a "<<" map key to the !!merge tag and emits it bare, so now that YAML.decode honors merge keys, decoding YAML.encode(["<<": 1]) failed instead of round-tripping. Encode through a yaml.Node and retag every "<<" key as a double-quoted string. Signed-off-by: Alex Suraci <[email protected]>
Encoding through a yaml.Node tags every "<<" string !!merge, not just keys, so a "<<" value came out as `a: !!merge <<`. Retag those as strings too; they emit plain, as before the node round-trip. Signed-off-by: Alex Suraci <[email protected]>
yaml.Node.Encode emits YAML and parses it back, which broke encoding a multi-line string led by a tab and reshaped newline-only strings. Marshal the plain tree as before, and swap only a "<<" key, in the maps that have one, for a key type whose MarshalYAML yields a double-quoted string node. Signed-off-by: Alex Suraci <[email protected]>
Deploying dang with
|
| Latest commit: |
dcbaed1
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f6a13cc9.dang-3kk.pages.dev |
| Branch Preview URL: | https://yaml-merge-keys.dang-3kk.pages.dev |
sipsma
added a commit
to grouville/dagger
that referenced
this pull request
Nov 3, 2026
The engine pinned Guillaume's fork of Dang for vito/dang#211, which adds PrepareDir and PreparedDirectory.Evaluate. vito/dang#250 carried that change onto Dang main and merged, so Dang now moves to its merge commit and the replace of the fork goes away. Since the merge of vito/dang#213 that Dang was on before, Dang's type checker became stricter (vito/dang#230 to #235, #246 and #249): programs it accepted that could fail at runtime are now type errors, so a module that loaded before may now fail to load. Among them, operators need non-null operands, Map.get is typed as nullable (vito/dang#215), and a decode result must be given a type before it is used. Function parameters match by name, so a positional call through an interface binds in the interface's order. YAML << merge keys are resolved when decoding (vito/dang#217), and malformed syntax is reported instead of panicking the parser (vito/dang#243). The release note describes what module authors will see. Signed-off-by: Erik Sipsma <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
YAML.decodekept a<<merge key as a literal"<<"entry. So a common config pattern failed to decode into records or maps:Before this change, decoding that as
Map[Service!]!failed with["web"]["<<"]: expected ... got object.Decoding
Merge keys now follow the YAML merge-key spec:
<<).<<: [*a, *b], earlier mappings win over later ones."<<"is an ordinary key.a: <<: merge value must be a mapping or a sequence of mappings. Self-merges hit the existing cyclic-alias check.Encoding
yaml.v3 writes a
"<<"map key bare (<<: 1). With merges honored,YAML.decode(YAML.encode(["<<": 1]))would therefore have failed. In maps that have a"<<"key, that key is swapped for a type whoseMarshalYAMLreturns a double-quoted string node, so it comes out as"<<": 1. Everything else still goes straight throughyaml.Marshal, so other output is the same as before, including"<<"values (a: <<).An earlier version of the fix built a
yaml.NodewithNode.Encode. That method re-parses its own output, which broke tab-led multi-line strings; it was replaced, and a test covers that case.Tests are in
tests/test_from_yaml.dang: merges into maps and records, the precedence rules, inline merges, quoted"<<", the error, and encode round-trips. The docs (docs/lit/data/json-yaml.md, skillstdlib.md) describe merge-key handling.