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

Parser reports false positive error on yaml with anchors #284

Closed
evidolob opened this issue Jun 15, 2021 · 2 comments
Closed

Parser reports false positive error on yaml with anchors #284

evidolob opened this issue Jun 15, 2021 · 2 comments

Comments

@evidolob
Copy link

Describe the bug
When parser parses this yaml:

default: &DEFAULT
  name: Anchor
customname: &CUSTOMNAME
  custom_name: Anchor
anchor_test:
  <<: *DEFAULT
  <<: *CUSTOMNAME

It reports error: Map keys must be unique. But this is valid yaml.

To Reproduce
Just parse yaml provided in description.

Expected behaviour
Parser shouldn't report duplicate key errors on anchor references.

Versions (please complete the following information):

  • Environment: Node.js 12.7.0
  • yaml: 2.0.0-6

Additional context
Found during work on redhat-developer/yaml-language-server#442

@evidolob evidolob added the bug Something isn't working label Jun 15, 2021
@eemeli
Copy link
Owner

eemeli commented Jun 15, 2021

Your example is valid YAML 1.1, but we're defaulting to YAML 1.2, which does not consider << as any sort of special key.

To parse this as you expect, you may use either the merge: true or version: '1.1' options.

@eemeli eemeli removed the bug Something isn't working label Jun 15, 2021
@evidolob
Copy link
Author

yes, I totally miss that, thank you!

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

No branches or pull requests

2 participants