Skip to content

Resolve YAML aliases in YAML::Any#15941

Merged
straight-shoota merged 3 commits intocrystal-lang:masterfrom
willhbr:willhbr/push-lswqpmzkpqwu
Jul 19, 2025
Merged

Resolve YAML aliases in YAML::Any#15941
straight-shoota merged 3 commits intocrystal-lang:masterfrom
willhbr:willhbr/push-lswqpmzkpqwu

Conversation

@willhbr
Copy link
Contributor

@willhbr willhbr commented Jun 30, 2025

Fixes #15937 where YAML::Any will not correctly merge aliases into maps.

This file is parsed correctly:

hello: &single_alias world
single: *single_alias

map: &map_alias
  foo: bar
splatted: *map_alias
modified:
  <<: *map_alias
  food: bark
nonsense:
  <<: *single_alias

With this patch the result is:

hello: world
single: world
map:
  foo: bar
splatted:
  foo: bar
modified:
  foo: bar
  food: bark
nonsense:
  <<: world

With 1.16.3 the result is:

hello: world
single: world
map:
  foo: bar
splatted:
  foo: bar
modified:
  <<:
    foo: bar
  food: bark
nonsense:
  <<: world

(note the << submessage in modified that should have been splatted into the outer map).

I'm not sure if this is the best way to fix the issue, I don't really have a good understanding of how all the YAML parsing fits together, so I could totally be putting an inappropriate bandaid on this.

@straight-shoota straight-shoota added this to the 1.18.0 milestone Jul 17, 2025
@straight-shoota straight-shoota merged commit a2ac58a into crystal-lang:master Jul 19, 2025
38 checks passed
@willhbr willhbr deleted the willhbr/push-lswqpmzkpqwu branch July 27, 2025 08:22
@straight-shoota straight-shoota changed the title Resolve aliases in YAML::Any Resolve YAML aliases in YAML::Any Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

YAML::Any.from_yaml does not resolve aliases in document

3 participants