# YAML Test Matrix

--- &test-X38W
  Title: Aliases in Flow Objects
  Tags: [ alias, complex-key, flow ]

YAML

{ &a [a, &b b]: *b, *a : [c, *b, d]}

Expected Events

+STR
+DOC
+MAP {}
+SEQ [] &a
=VAL :a
=VAL &b :b
-SEQ
=ALI *b
=ALI *a
+SEQ []
=VAL :c
=ALI *b
=VAL :d
-SEQ
-MAP
-DOC
-STR

Expected JSON



c-libfyaml-event

 ok

c-libyaml-event

 ok

cpp-yamlcpp-event

 ok

dotnet-yamldotnet-event

 ok

hs-hsyaml-event

 ok

js-yaml-event

 ok

nim-nimyaml-event

 ok

perl-pp-event

 ok

perl-refparser-event

 ok

py-pyyaml-event

 ok

py-ruamel-event

 ok

rust-yamlrust-event

 ok

cpp-rapidyaml-event

 diff
Minimal Events:
+STR
+DOC
+MAP
+SEQ &a
=VAL :a
=VAL &b :b
-SEQ
=ALI *b
=ALI *a
+SEQ
=VAL :c
=ALI *b
=VAL :d
-SEQ
-MAP
-DOC
-STR
Transformed Events:
+STR
+DOC
+MAP
=VAL &a :[a
=VAL :
=VAL &b :b]
=ALI *b
=ALI *a
+SEQ
=VAL :c
=ALI *b
=VAL :d
-SEQ
-MAP
-DOC
-STR
Got Events:
+STR
+DOC
+MAP
=VAL &a :[a
=VAL :
=VAL &b :b]
=ALI *b
=ALI *a
+SEQ
=VAL :c
=ALI *b
=VAL :d
-SEQ
-MAP
-DOC
-STR

perl-pp-perl

 error
Duplicate key '['a','b']' at /perl5/lib/perl5/YAML/PP/Parser.pm line 61.
 at /perl5/lib/perl5/YAML/PP/Loader.pm line 94.

perl-pplibyaml-perl

 error
Duplicate key '['a','b']' at /perl5/lib/perl5/YAML/PP/Parser.pm line 61.

perl-yaml-perl

 error
YAML Error: Invalid element in map
   Code: YAML_LOAD_ERR_BAD_MAP_ELEMENT
   Line: 1
   Document: 1
 at /perl5/lib/perl5/YAML/Loader.pm line 360.

py-pyyaml-py

 error
Traceback (most recent call last):
  File "/yaml/bin/py-pyyaml-py", line 36, in <module>
    for doc in yaml.load_all(sys.stdin.read(), Loader=yaml.FullLoader):
  File "/python/lib/python3.12/site-packages/yaml/__init__.py", line 130, in load_all
    yield loader.get_data()
          ^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 45, in get_data
    return self.construct_document(self.get_node())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 60, in construct_document
    for dummy in generator:
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 413, in construct_yaml_map
    value = self.construct_mapping(node)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 218, in construct_mapping
    return super().construct_mapping(node, deep=deep)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 141, in construct_mapping
    raise ConstructorError("while constructing a mapping", node.start_mark,
yaml.constructor.ConstructorError: while constructing a mapping
  in "<unicode string>", line 1, column 1:
    { &a [a, &b b]: *b, *a : [c, *b, d]}
    ^
found unhashable key
  in "<unicode string>", line 1, column 3:
    { &a [a, &b b]: *b, *a : [c, *b, d]}
      ^

py-ruamel-py

 error
Traceback (most recent call last):
  File "/yaml/bin/py-ruamel-py", line 38, in <module>
    for doc in yaml.load_all(sys.stdin.read()):
  File "/python/lib/python3.12/site-packages/ruamel/yaml/main.py", line 476, in load_all
    yield constructor.get_data()
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/constructor.py", line 110, in get_data
    return self.construct_document(self.composer.get_node())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/constructor.py", line 125, in construct_document
    for _dummy in generator:
  File "/python/lib/python3.12/site-packages/ruamel/yaml/constructor.py", line 633, in construct_yaml_map
    value = self.construct_mapping(node)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/constructor.py", line 429, in construct_mapping
    return BaseConstructor.construct_mapping(self, node, deep=deep)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/constructor.py", line 246, in construct_mapping
    if self.check_mapping_key(node, key_node, mapping, key, value):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/constructor.py", line 278, in check_mapping_key
    raise DuplicateKeyError(*args)
ruamel.yaml.constructor.DuplicateKeyError: while constructing a mapping
  in "<unicode string>", line 1, column 1:
    { &a [a, &b b]: *b, *a : [c, *b, d]}
    ^ (line: 1)
found duplicate key "('a', 'b')" with value "[]" (original value: "b")
  in "<unicode string>", line 1, column 3:
    { &a [a, &b b]: *b, *a : [c, *b, d]}
      ^ (line: 1)

To suppress this check see:
    http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys

c-libfyaml-json

 na
stdin:1:1: error: duplicate key after resolving
{ &a [a, &b b]: *b, *a : [c, *b, d]}
^

dotnet-yamldotnet-json

 na
{? ["a", "b"] : ["c", "b", "d"]}

go-yaml-json

 na
yaml: invalid map key: []interface {}{"a", "b"}

hs-hsyaml-json

 na
{"[\"a\",\"b\"]":["c","b","d"]}

hs-reference-yeast

 na
Line  Col Char Byte Token|Content
   1    0    0    0 +DOC |
   1    0    0    0 +NODE|
   1    0    0    0 +MAP |
   1    0    0    0 =SYNX|{
   1    1    1    1 =WSPC|.
   1    2    2    2 +PAIR|
   1    2    2    2 +NODE|
   1    2    2    2 +PROP|
   1    2    2    2 +ANCH|
   1    2    2    2 =SYNX|&
   1    3    3    3 =META|a
   1    4    4    4 -ANCH|
   1    4    4    4 -PROP|
   1    4    4    4 +VAL |
   1    4    4    4 -VAL |
   1    4    4    4 -NODE|
   1    4    4    4 +NODE|
   1    4    4    4 +VAL |
   1    4    4    4 -VAL |
   1    4    4    4 -NODE|
   1    4    4    4 -PAIR|
   1    4    4    4 =WSPC|.
   1    5    5    5 -MAP |
   1    5    5    5 -NODE|
   1    5    5    5 =ERR |Unexpected.'['
   1    5    5    5 =REST|[a,.&b.b]:.*b,.*a.:.[c,.*b,.d]}
   1   36   36   36 =REST|\x0a
   2    0   37   37 -DOC |

js-jsyaml-json

 na
/node/node_modules/js-yaml/lib/loader.js:187
  throw generateError(state, message);
  ^
YAMLException: duplicated mapping key (1:21)

 1 | { &a [a, &b b]: *b, *a : [c, *b, d]}
-------------------------^
    at generateError (/node/node_modules/js-yaml/lib/loader.js:183:10)
    at throwError (/node/node_modules/js-yaml/lib/loader.js:187:9)
    at storeMappingPair (/node/node_modules/js-yaml/lib/loader.js:358:7)
    at readFlowCollection (/node/node_modules/js-yaml/lib/loader.js:796:7)
    at composeNode (/node/node_modules/js-yaml/lib/loader.js:1442:11)
    at readBlockMapping (/node/node_modules/js-yaml/lib/loader.js:1104:12)
    at composeNode (/node/node_modules/js-yaml/lib/loader.js:1441:12)
    at readDocument (/node/node_modules/js-yaml/lib/loader.js:1625:3)
    at loadDocuments (/node/node_modules/js-yaml/lib/loader.js:1688:5)
    at Object.loadAll (/node/node_modules/js-yaml/lib/loader.js:1701:19) {
  reason: 'duplicated mapping key',
  mark: {
    name: null,
    buffer: '{ &a [a, &b b]: *b, *a : [c, *b, d]}\n',
    position: 20,
    line: 0,
    column: 20,
    snippet: ' 1 | { &a [a, &b b]: *b, *a : [c, *b, d]}\n-------------------------^'
  }
}

Node.js v20.13.1

js-yaml-json

 na
{
  "[ a, &b b ]": "b",
  "*a": [
    "c",
    "b",
    "d"
  ]
}
(node:4023) Warning: Keys with collection values will be stringified due to JS Object restrictions: "[ a, &b b ]". Set mapAsMap: true to use object keys.
(Use `node --trace-warnings ...` to show where the warning was created)

lua-lyaml-json

 na
luajit: /yaml/bin/lua-lyaml-json:8: Cannot serialise table: table key must be a number or string
stack traceback:
	[C]: in function 'encode'
	/yaml/bin/lua-lyaml-json:8: in main chunk
	[C]: at 0x55eedc8deed0

perl-pp-json

 na
Duplicate key '['a','b']' at /perl5/lib/perl5/YAML/PP/Parser.pm line 61.
 at /perl5/lib/perl5/YAML/PP/Loader.pm line 94.

perl-pplibyaml-json

 na
Duplicate key '['a','b']' at /perl5/lib/perl5/YAML/PP/Parser.pm line 61.

perl-syck-json

 na
{
   "ARRAY(0x7faae8632830)" : [
      "c",
      "b",
      "d"
   ]
}

perl-syck-perl

 na
{
  'ARRAY(0x7f214f492ae8)' => [
                               'c',
                               'b',
                               'd'
                             ]
}

perl-tiny-json

 na
YAML::Tiny found illegal characters in plain scalar: '*b, *a : [c, *b, d]}' at /yaml/bin/perl-tiny-json line 12.

perl-xs-json

 na
{
   "ARRAY(0x7fdab6b578e0)" : [
      "c",
      "b",
      "d"
   ]
}

perl-xs-perl

 na
{
  'ARRAY(0x7f3dba079608)' => [
                               'c',
                               'b',
                               'd'
                             ]
}

perl-yaml-json

 na
YAML Error: Invalid element in map
   Code: YAML_LOAD_ERR_BAD_MAP_ELEMENT
   Line: 1
   Document: 1
 at /perl5/lib/perl5/YAML/Loader.pm line 360.

py-pyyaml-json

 na
Traceback (most recent call last):
  File "/yaml/bin/py-pyyaml-json", line 19, in <module>
    for doc in yaml.load_all(sys.stdin.read(), Loader=yaml.FullLoader):
  File "/python/lib/python3.12/site-packages/yaml/__init__.py", line 130, in load_all
    yield loader.get_data()
          ^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 45, in get_data
    return self.construct_document(self.get_node())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 60, in construct_document
    for dummy in generator:
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 413, in construct_yaml_map
    value = self.construct_mapping(node)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 218, in construct_mapping
    return super().construct_mapping(node, deep=deep)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 141, in construct_mapping
    raise ConstructorError("while constructing a mapping", node.start_mark,
yaml.constructor.ConstructorError: while constructing a mapping
  in "<unicode string>", line 1, column 1:
    { &a [a, &b b]: *b, *a : [c, *b, d]}
    ^
found unhashable key
  in "<unicode string>", line 1, column 3:
    { &a [a, &b b]: *b, *a : [c, *b, d]}
      ^

py-ruamel-json

 na
Traceback (most recent call last):
  File "/yaml/bin/py-ruamel-json", line 21, in <module>
    for doc in yaml.load_all(sys.stdin.read()):
  File "/python/lib/python3.12/site-packages/ruamel/yaml/main.py", line 476, in load_all
    yield constructor.get_data()
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/constructor.py", line 110, in get_data
    return self.construct_document(self.composer.get_node())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/constructor.py", line 125, in construct_document
    for _dummy in generator:
  File "/python/lib/python3.12/site-packages/ruamel/yaml/constructor.py", line 633, in construct_yaml_map
    value = self.construct_mapping(node)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/constructor.py", line 429, in construct_mapping
    return BaseConstructor.construct_mapping(self, node, deep=deep)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/constructor.py", line 246, in construct_mapping
    if self.check_mapping_key(node, key_node, mapping, key, value):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/constructor.py", line 278, in check_mapping_key
    raise DuplicateKeyError(*args)
ruamel.yaml.constructor.DuplicateKeyError: while constructing a mapping
  in "<unicode string>", line 1, column 1:
    { &a [a, &b b]: *b, *a : [c, *b, d]}
    ^ (line: 1)
found duplicate key "('a', 'b')" with value "[]" (original value: "b")
  in "<unicode string>", line 1, column 3:
    { &a [a, &b b]: *b, *a : [c, *b, d]}
      ^ (line: 1)

To suppress this check see:
    http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys

ruby-psych-json

 na
{"[\"a\", \"b\"]":["c","b","d"]}

perl-tiny-perl

 ni
YAML::Tiny found illegal characters in plain scalar: '*b, *a : [c, *b, d]}' at /yaml/bin/perl-tiny-perl line 15.