# YAML Test Matrix

--- &test-2SXE
  Title: Anchors With Colon in Name
  Tags: [ 1.3-err, alias, edge, mapping ]

YAML

&a: key: &a value
foo:
  *a:

Expected Events

+STR
+DOC
+MAP
=VAL &a: :key
=VAL &a :value
=VAL :foo
=ALI *a:
-MAP
-DOC
-STR

Expected JSON

{
"foo": "key",
"key": "value"
}

c-libfyaml-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-ruamel-event

 ok

c-libfyaml-json

 json_ok

dotnet-yamldotnet-json

 json_ok

hs-hsyaml-json

 json_ok

js-yaml-json

 json_ok

perl-pp-json

 json_ok

py-ruamel-json

 json_ok

cpp-rapidyaml-event

 diff
Minimal Events:
+STR
+DOC
+MAP
=VAL &a: :key
=VAL &a :value
=VAL :foo
=ALI *a:
-MAP
-DOC
-STR
Transformed Events:
+STR
+DOC
+MAP
=VAL &a: :key
=VAL &a :value
=VAL :foo
+MAP
=ALI *a
=VAL :
-MAP
-MAP
-DOC
-STR
Got Events:
+STR
+DOC
+MAP
=VAL &a: :key
=VAL &a :value
=VAL :foo
+MAP
=ALI *a
=VAL :
-MAP
-MAP
-DOC
-STR

perl-yaml-json

 json_diff
{
  "": "key: &a value",
  "foo": {
    "": null
  }
}

c-libyaml-event

 error
+STR
+DOC
+MAP
=VAL &a :
=VAL :key
Parse error: mapping values are not allowed in this context

go-yaml-json

 error
yaml: mapping values are not allowed in this context

js-jsyaml-json

 error
/node/node_modules/js-yaml/lib/loader.js:187
  throw generateError(state, message);
  ^
YAMLException: end of the stream or a document separator is expected (1:8)

 1 | &a: key: &a value
------------^
 2 | foo:
 3 |   *a:
    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 readDocument (/node/node_modules/js-yaml/lib/loader.js:1645:5)
    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)
    at Object.<anonymous> (/yaml/bin/js-jsyaml-json:7:13)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12) {
  reason: 'end of the stream or a document separator is expected',
  mark: {
    name: null,
    buffer: '&a: key: &a value\nfoo:\n  *a:\n',
    position: 7,
    line: 0,
    column: 7,
    snippet: ' 1 | &a: key: &a value\n------------^\n 2 | foo:\n 3 |   *a:'
  }
}

Node.js v20.13.1

lua-lyaml-json

 error
luajit: 1:5: mapping values are not allowed in this context
stack traceback:
	[C]: in function 'error'
	/usr/local/share/lua/5.1/lyaml/init.lua:306: in function 'error'
	/usr/local/share/lua/5.1/lyaml/init.lua:325: in function 'parse'
	/usr/local/share/lua/5.1/lyaml/init.lua:443: in function 'load_node'
	/usr/local/share/lua/5.1/lyaml/init.lua:340: in function 'load_node'
	/usr/local/share/lua/5.1/lyaml/init.lua:497: in function 'load'
	/yaml/bin/lua-lyaml-json:6: in main chunk
	[C]: at 0x55ab47448ed0

perl-pplibyaml-json

 error
YAML::PP::LibYAML Error: The problem:

    mapping values are not allowed in this context

was found at , line: 1, column: 8

perl-pplibyaml-perl

 error
YAML::PP::LibYAML Error: The problem:

    mapping values are not allowed in this context

was found at , line: 1, column: 8

perl-syck-json

 error
Syck parser (line 1, column 3): syntax error at /perl5/lib/perl5/x86_64-linux-thread-multi/YAML/Syck.pm line 60, <> line 1.

perl-syck-perl

 error
Syck parser (line 1, column 3): syntax error at /perl5/lib/perl5/x86_64-linux-thread-multi/YAML/Syck.pm line 60, <> line 1.

perl-xs-json

 error
Use of uninitialized value in subroutine entry at /yaml/bin/perl-xs-json line 14, <> line 1.
YAML::XS::Load Error: The problem:

    mapping values are not allowed in this context

was found at document: 1, line: 1, column: 8

perl-xs-perl

 error
Use of uninitialized value in subroutine entry at /yaml/bin/perl-xs-perl line 16, <> line 1.
YAML::XS::Load Error: The problem:

    mapping values are not allowed in this context

was found at document: 1, line: 1, column: 8

py-pyyaml-event

 error
+STR
+DOC
+MAP
=VAL &a :
=VAL :key
Traceback (most recent call last):
  File "/yaml/bin/py-pyyaml-event", line 7, in <module>
    for event in yaml.parse(sys.stdin.read()):
  File "/python/lib/python3.12/site-packages/yaml/__init__.py", line 75, in parse
    while loader.check_event():
          ^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
                         ^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/parser.py", line 428, in parse_block_mapping_key
    if self.check_token(KeyToken):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 116, in check_token
    self.fetch_more_tokens()
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 223, in fetch_more_tokens
    return self.fetch_value()
           ^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 577, in fetch_value
    raise ScannerError(None, None,
yaml.scanner.ScannerError: mapping values are not allowed here
  in "<unicode string>", line 1, column 8:
    &a: key: &a value
           ^

py-pyyaml-json

 error
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/composer.py", line 27, in get_node
    return self.compose_document()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 127, in compose_mapping_node
    while not self.check_event(MappingEndEvent):
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
                         ^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/parser.py", line 428, in parse_block_mapping_key
    if self.check_token(KeyToken):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 116, in check_token
    self.fetch_more_tokens()
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 223, in fetch_more_tokens
    return self.fetch_value()
           ^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 577, in fetch_value
    raise ScannerError(None, None,
yaml.scanner.ScannerError: mapping values are not allowed here
  in "<unicode string>", line 1, column 8:
    &a: key: &a value
           ^

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/composer.py", line 27, in get_node
    return self.compose_document()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 127, in compose_mapping_node
    while not self.check_event(MappingEndEvent):
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
                         ^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/parser.py", line 428, in parse_block_mapping_key
    if self.check_token(KeyToken):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 116, in check_token
    self.fetch_more_tokens()
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 223, in fetch_more_tokens
    return self.fetch_value()
           ^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 577, in fetch_value
    raise ScannerError(None, None,
yaml.scanner.ScannerError: mapping values are not allowed here
  in "<unicode string>", line 1, column 8:
    &a: key: &a value
           ^

ruby-psych-json

 error
/ruby/gems/psych/lib/psych.rb:458:in `parse': (<unknown>): mapping values are not allowed in this context at line 1 column 8 (Psych::SyntaxError)
	from /ruby/gems/psych/lib/psych.rb:458:in `parse_stream'
	from /ruby/gems/psych/lib/psych.rb:632:in `load_stream'
	from /yaml/bin/ruby-psych-json:6:in `<main>'

rust-yamlrust-event

 error
+STR
+DOC
+MAP
=VAL &1 :
=VAL :key
Error: ScanError { mark: Marker { index: 7, line: 1, col: 7 }, info: "mapping values are not allowed in this context" }

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 +PAIR|
   1    0    0    0 +NODE|
   1    0    0    0 +PROP|
   1    0    0    0 +ANCH|
   1    0    0    0 =SYNX|&
   1    1    1    1 =META|a:
   1    3    3    3 -ANCH|
   1    3    3    3 -PROP|
   1    3    3    3 =WSPC|.
   1    4    4    4 +VAL |
   1    4    4    4 =TEXT|key
   1    7    7    7 -VAL |
   1    7    7    7 -NODE|
   1    7    7    7 =SYNX|:
   1    8    8    8 =WSPC|.
   1    9    9    9 +NODE|
   1    9    9    9 +PROP|
   1    9    9    9 +ANCH|
   1    9    9    9 =SYNX|&
   1   10   10   10 =META|a
   1   11   11   11 -ANCH|
   1   11   11   11 -PROP|
   1   11   11   11 =WSPC|.
   1   12   12   12 +VAL |
   1   12   12   12 =TEXT|value
   1   17   17   17 -VAL |
   1   17   17   17 -NODE|
   1   17   17   17 =EOL |\x0a
   2    0   18   18 -PAIR|
   2    0   18   18 +PAIR|
   2    0   18   18 +NODE|
   2    0   18   18 +VAL |
   2    0   18   18 =TEXT|foo
   2    3   21   21 -VAL |
   2    3   21   21 -NODE|
   2    3   21   21 =SYNX|:
   2    4   22   22 =EOL |\x0a
   3    0   23   23 =DENT|.
   3    1   24   24 =WSPC|.
   3    2   25   25 +NODE|
   3    2   25   25 +ALI |
   3    2   25   25 =SYNX|*
   3    3   26   26 =META|a:
   3    5   28   28 -ALI |
   3    5   28   28 -NODE|
   3    5   28   28 =EOL |\x0a
   4    0   29   29 -PAIR|
   4    0   29   29 -MAP |
   4    0   29   29 -NODE|
   4    0   29   29 -DOC |

perl-pp-perl

 na
{
  'foo' => 'key',
  'key' => 'value'
}

perl-yaml-perl

 na
{
  '' => 'key: &a value',
  'foo' => {
             '' => undef
           }
}

py-ruamel-py

 na
{'foo': 'key', 'key': 'value'}

perl-tiny-json

 ni
YAML::Tiny found illegal characters in plain scalar: 'key: &a value' at /yaml/bin/perl-tiny-json line 12.

perl-tiny-perl

 ni
YAML::Tiny found illegal characters in plain scalar: 'key: &a value' at /yaml/bin/perl-tiny-perl line 15.