Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support reading of properties on implicit block mapping keys #561

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dota17
Copy link

@dota17 dota17 commented Jun 30, 2020

now , the following yaml document can be loaded

&anchor foo:
  foo: bar
  *anchor: duplicate key
  baz: bat
  *anchor: duplicate key

@perlpunk
Copy link

Note that the example is invalid YAML.
There needs to be a space after an alias key before the colon (because a colon can be part of an anchor/alias).
It should be:

  *anchor : duplicate key

@rlidwka
Copy link
Member

rlidwka commented Dec 1, 2020

pyyaml parses this, however http://ben-kiki.org/ypaste/ (which is specified as reference parser) does not.

Gonna check it again later, but I think we should require a space after colon there?

@perlpunk
Copy link

perlpunk commented Dec 1, 2020

pyyaml and libyaml can parse it, but that is actually a bug.

@yuriy-yarosh
Copy link

And what about object / array anchor merging ?
Is it a valid syntax for Yaml 1.2 ?

"@figen/config-eslint@*":
  dependencies: &eslint
    "eslint": "8.55.0"
    
"@figen/config-typescript@*":
  dependencies: &typescript
    "typescript": "^5.3.3"
      
"figen@*":
  dependencies:
    << : {*eslint, *typescript}

@perlpunk
Copy link

perlpunk commented Jan 1, 2024

Correct would be:

<< : [*eslint, *typescript]

The syntax itself is correct. The parser doesn't know anything about << - it is just a string at this point.
The constructor detects it as a merge key, and that depends on library if it allows this for YAML 1.2. It should not be enabled by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants