ruyaml icon indicating copy to clipboard operation
ruyaml copied to clipboard

Use of alias as a map key requires a space between alias map key and the colon

Open EnGamma opened this issue 3 years ago • 2 comments

YAML code snippet:

stuff:
    key1: &k1 'map_key1'
    key2: &k2 'map_key2`
    *k1 : value1 # works, but requires space before colon
    *k2: value2  # fails with "could not find expected ':'"

PyYAML accepts no space between map key and colon, but ruyaml does not

EnGamma avatar Feb 09 '22 20:02 EnGamma

k2: is a valid alias name in YAML (unfortunately). PyYAML and libyaml implemented this wrong, although I can understand the decision to not support colons in alias names.

Therefor, a space is required if an alias is used as a key (so the title of this issue is right). This is one of the things that might get removed in the next YAML version, and then the space wouldn't be required anymore, but until then, it's necessary.

perlpunk avatar Feb 10 '22 23:02 perlpunk

Good to know. Thanks for the response.

EnGamma avatar Feb 11 '22 01:02 EnGamma