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

Fix anchor reference issue in Map keys #454

Closed

Conversation

buty4649
Copy link
Contributor

This PR fixes a bug where an extra colon : is appended to the anchor reference name when used in Map keys.

Reproduction Steps

Parsing the following ng.yaml with ./tools/ryml-yaml-events results in an error.

$ cat ng.yaml
abc: &foo FOO
*foo: bar

$ ./build/tools/ryml-yaml-events ng.yaml
ng.yaml:2:7: (20B): ERROR: could not find ':' colon after key
ng.yaml:2:7: *foo: bar  (size=9)
                   ^~~  (cols 7-10)

@biojppm
Copy link
Owner

biojppm commented Aug 10, 2024

TLDR; the problem is with your YAML, not with the library.


Sorry, but the existing behavior is correct, and adheres to the standard.

An anchor can legally have a trailing semicolon, so the semicolon immediately after a reference is understood as part of the reference. It is what it is.

See example with space and the same example without space.

FYI, before the recent release, rapidyaml was incorrect; this was fixed and that's why you now see the problem with this release.

@buty4649
Copy link
Contributor Author

Thank you for your reply and for explaining the details of the specification. I wasn't aware that an anchor could legally include a :. I had misunderstood because libyaml does not allow a : in this context.

As you pointed out, my changes are against the YAML specification, so I will close this PR.

@buty4649 buty4649 closed this Aug 14, 2024
@buty4649 buty4649 deleted the fix-anchor-reference-map-key branch August 14, 2024 16:05
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.

2 participants