# YAML Test Matrix

--- &test-4FJ6
  Title: Nested implicit complex keys
  Tags: [ complex-key, flow, mapping, sequence ]

YAML

---
[
  [ a, [ [[b,c]]: d, e]]: 23
]

Expected Events

+STR
+DOC ---
+SEQ []
+MAP {}
+SEQ []
=VAL :a
+SEQ []
+MAP {}
+SEQ []
+SEQ []
=VAL :b
=VAL :c
-SEQ
-SEQ
=VAL :d
-MAP
=VAL :e
-SEQ
-SEQ
=VAL :23
-MAP
-SEQ
-DOC
-STR

Expected JSON



c-libfyaml-event

 ok

c-libyaml-event

 ok

cpp-yamlcpp-event

 ok

dotnet-yamldotnet-event

 ok

hs-hsyaml-event

 ok

java-snakeyaml-event

 ok

js-yaml-event

 ok

nim-nimyaml-event

 ok

perl-pplibyaml-event

 ok

perl-refparser-event

 ok

py-pyyaml-event

 ok

py-ruamel-event

 ok

perl-pp-event

 error
+STR
+DOC ---
+SEQ []
+SEQ []
=VAL :a
+SEQ []
+SEQ []
+SEQ []
=VAL :b
=VAL :c
-SEQ
-SEQ
Line      : 3
Column    : 17
Expected  : EOL FLOWSEQ_END FLOW_COMMA WS
Got       : COLON
Where     : /perl5/lib/perl5/YAML/PP/Parser.pm line 392
YAML      : ": d, e]]: 23\n"
  at /yaml/bin/perl-pp-event line 25.

perl-pp-perl

 error
Line      : 3
Column    : 17
Expected  : EOL FLOWSEQ_END FLOW_COMMA WS
Got       : COLON
Where     : /perl5/lib/perl5/YAML/PP/Parser.pm line 392
YAML      : ": d, e]]: 23\n"
  at /perl5/lib/perl5/YAML/PP/Loader.pm line 94.

perl-yaml-perl

 error
YAML Error: Expected separator '---'
   Code: YAML_PARSE_ERR_NO_SEPARATOR
   Line: 2
   Document: 2
 at /perl5/lib/perl5/YAML/Loader.pm line 88.

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.7/site-packages/yaml/__init__.py", line 130, in load_all
    yield loader.get_data()
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 45, in get_data
    return self.construct_document(self.get_node())
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 60, in construct_document
    for dummy in generator:
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 413, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 218, in construct_mapping
    return super().construct_mapping(node, deep=deep)
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 142, in construct_mapping
    "found unhashable key", key_node.start_mark)
yaml.constructor.ConstructorError: while constructing a mapping
found unhashable key
  in "<unicode string>", line 3, column 3:
      [ a, [ [[b,c]]: d, e]]: 23
      ^

py-ruamel-py

 error
Traceback (most recent call last):
  File "/yaml/bin/py-ruamel-py", line 36, in <module>
    for doc in ruamel.yaml.load_all(sys.stdin.read(), Loader=ruamel.yaml.Loader):
  File "/python/lib/python3.7/site-packages/ruamel/yaml/main.py", line 976, in load_all
    yield loader._constructor.get_data()
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 106, in get_data
    return self.construct_document(self.composer.get_node())
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 123, in construct_document
    for _dummy in generator:
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 723, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 440, in construct_mapping
    return BaseConstructor.construct_mapping(self, node, deep=deep)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 231, in construct_mapping
    key = self.construct_object(key_node, deep=True)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 146, in construct_object
    data = self.construct_non_recursive_object(node)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 188, in construct_non_recursive_object
    for _dummy in generator:
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 717, in construct_yaml_seq
    data.extend(self.construct_sequence(node))
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 211, in construct_sequence
    return [self.construct_object(child, deep=deep) for child in node.value]
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 211, in <listcomp>
    return [self.construct_object(child, deep=deep) for child in node.value]
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 146, in construct_object
    data = self.construct_non_recursive_object(node)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 188, in construct_non_recursive_object
    for _dummy in generator:
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 717, in construct_yaml_seq
    data.extend(self.construct_sequence(node))
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 211, in construct_sequence
    return [self.construct_object(child, deep=deep) for child in node.value]
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 211, in <listcomp>
    return [self.construct_object(child, deep=deep) for child in node.value]
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 146, in construct_object
    data = self.construct_non_recursive_object(node)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 188, in construct_non_recursive_object
    for _dummy in generator:
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 723, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 440, in construct_mapping
    return BaseConstructor.construct_mapping(self, node, deep=deep)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 257, in construct_mapping
    if self.check_mapping_key(node, key_node, mapping, key, value):
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 267, in check_mapping_key
    if key in mapping:
TypeError: unhashable type: 'list'

c-libfyaml-json

 na
[
  {
]
stdin:3:3: error: Non scalar keys are not allowed in JSON emit mode
  [ a, [ [[b,c]]: d, e]]: 23
  ^~~~~~~~~~~~~~~~~~~~~~

dotnet-yamldotnet-json

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

hs-hsyaml-json

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

java-snakeyaml-json

 na
[
  {
    "[a, [{[[b, c]]\u003dd}, e]]": 23
  }
]

js-jsyaml-json

 na
/node/node_modules/js-yaml/lib/loader.js:187
  throw generateError(state, message);
  ^
YAMLException: nested arrays are not supported inside keys (3:20)

 1 | ---
 2 | [
 3 |   [ a, [ [[b,c]]: d, e]]: 23
------------------------^
 4 | ]
    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:320:9)
    at readFlowCollection (/node/node_modules/js-yaml/lib/loader.js:798:20)
    at composeNode (/node/node_modules/js-yaml/lib/loader.js:1442:11)
    at readFlowCollection (/node/node_modules/js-yaml/lib/loader.js:780:5)
    at composeNode (/node/node_modules/js-yaml/lib/loader.js:1442:11)
    at readFlowCollection (/node/node_modules/js-yaml/lib/loader.js:780:5)
    at composeNode (/node/node_modules/js-yaml/lib/loader.js:1442:11)
    at readBlockMapping (/node/node_modules/js-yaml/lib/loader.js:1104:12)

js-yaml-json

 na
[
  {
    "[\n  a,\n  [\n      {\n          ? [ [ b, c ] ]\n          : d\n        },\n      e\n    ]\n]": 23
  }
]
(node:256) Warning: Keys with collection values will be stringified due to JS Object restrictions: "[ [ b, c ] ]". Set mapAsMap: true to use object keys.

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 0x56501aa86f97

perl-pp-json

 na
Line      : 3
Column    : 17
Expected  : EOL FLOWSEQ_END FLOW_COMMA WS
Got       : COLON
Where     : /perl5/lib/perl5/YAML/PP/Parser.pm line 392
YAML      : ": d, e]]: 23\n"
  at /perl5/lib/perl5/YAML/PP/Loader.pm line 94.

perl-pplibyaml-json

 na
[
   {
      "['a',[{'[[\\'b\\',\\'c\\']]' => 'd'},'e']]" : 23
   }
]

perl-pplibyaml-perl

 na
[
  {
    '[\'a\',[{\'[[\\\'b\\\',\\\'c\\\']]\' => \'d\'},\'e\']]' => 23
  }
]

perl-syck-json

 na
[
   {
      "ARRAY(0x55ee150cea98)" : 23
   }
]

perl-syck-perl

 na
[
  {
    'ARRAY(0x55b3f85520d8)' => 23
  }
]

perl-tiny-json

 na
YAML::Tiny failed to classify line '[' at /yaml/bin/perl-tiny-json line 12.

perl-xs-json

 na
[
   {
      "ARRAY(0x558fed48f1b0)" : 23
   }
]

perl-xs-perl

 na
[
  {
    'ARRAY(0x55c919551b58)' => 23
  }
]

perl-yaml-json

 na
YAML Error: Expected separator '---'
   Code: YAML_PARSE_ERR_NO_SEPARATOR
   Line: 2
   Document: 2
 at /perl5/lib/perl5/YAML/Loader.pm line 88.

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.7/site-packages/yaml/__init__.py", line 130, in load_all
    yield loader.get_data()
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 45, in get_data
    return self.construct_document(self.get_node())
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 60, in construct_document
    for dummy in generator:
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 413, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 218, in construct_mapping
    return super().construct_mapping(node, deep=deep)
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 142, in construct_mapping
    "found unhashable key", key_node.start_mark)
yaml.constructor.ConstructorError: while constructing a mapping
found unhashable key
  in "<unicode string>", line 3, column 3:
      [ a, [ [[b,c]]: d, e]]: 23
      ^

py-ruamel-json

 na
Traceback (most recent call last):
  File "/yaml/bin/py-ruamel-json", line 19, in <module>
    for doc in ruamel.yaml.load_all(sys.stdin.read(), Loader=ruamel.yaml.Loader):
  File "/python/lib/python3.7/site-packages/ruamel/yaml/main.py", line 976, in load_all
    yield loader._constructor.get_data()
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 106, in get_data
    return self.construct_document(self.composer.get_node())
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 123, in construct_document
    for _dummy in generator:
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 723, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 440, in construct_mapping
    return BaseConstructor.construct_mapping(self, node, deep=deep)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 231, in construct_mapping
    key = self.construct_object(key_node, deep=True)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 146, in construct_object
    data = self.construct_non_recursive_object(node)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 188, in construct_non_recursive_object
    for _dummy in generator:
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 717, in construct_yaml_seq
    data.extend(self.construct_sequence(node))
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 211, in construct_sequence
    return [self.construct_object(child, deep=deep) for child in node.value]
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 211, in <listcomp>
    return [self.construct_object(child, deep=deep) for child in node.value]
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 146, in construct_object
    data = self.construct_non_recursive_object(node)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 188, in construct_non_recursive_object
    for _dummy in generator:
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 717, in construct_yaml_seq
    data.extend(self.construct_sequence(node))
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 211, in construct_sequence
    return [self.construct_object(child, deep=deep) for child in node.value]
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 211, in <listcomp>
    return [self.construct_object(child, deep=deep) for child in node.value]
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 146, in construct_object
    data = self.construct_non_recursive_object(node)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 188, in construct_non_recursive_object
    for _dummy in generator:
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 723, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 440, in construct_mapping
    return BaseConstructor.construct_mapping(self, node, deep=deep)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 257, in construct_mapping
    if self.check_mapping_key(node, key_node, mapping, key, value):
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 267, in check_mapping_key
    if key in mapping:
TypeError: unhashable type: 'list'

ruby-psych-json

 na
[{"[\"a\", [{[[\"b\", \"c\"]]=>\"d\"}, \"e\"]]":23}]

perl-tiny-perl

 ni
YAML::Tiny failed to classify line '[' at /yaml/bin/perl-tiny-perl line 15.