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

Anchors are lost when their position is assigned a Node value #229

Closed
eemeli opened this issue Feb 13, 2021 · 1 comment
Closed

Anchors are lost when their position is assigned a Node value #229

eemeli opened this issue Feb 13, 2021 · 1 comment
Assignees
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@eemeli
Copy link
Owner

eemeli commented Feb 13, 2021

Describe the bug
When a node with an anchor is replaced by a different node, the anchor is lost and any aliases referring to it will fail to stringify properly.

To Reproduce

const doc = YAML.parseDocument('foo: &a A\nbar: *a\n')

// This modifies the existing Scalar
doc.set('foo', 'B')
String(doc)
// → 'foo: &a B\nbar: *a\n'

// This replaces the Scalar
doc.set('foo', doc.createNode('C'))
String(doc)
// → Uncaught Error: Alias node must be after source node

Expected behaviour
Either anchors should be automatically re-assigned, or it should bepossible/easy to ensure that happens.

Versions (please complete the following information):

  • yaml: all

Additional context
This is effectively a different expression of the "Fix self-referential aliases on custom collections" todo item on #203, as a good solution to this will also provide a good solution to that.

@eemeli eemeli added the bug Something isn't working label Feb 13, 2021
@eemeli eemeli mentioned this issue Feb 13, 2021
14 tasks
@eemeli eemeli self-assigned this Mar 13, 2021
@eemeli eemeli added the wontfix This will not be worked on label Mar 27, 2021
@eemeli
Copy link
Owner Author

eemeli commented Mar 27, 2021

The original buggy part of this is getting fixed by #248, so I'm going to close this for now. The wontfix label is here for the surprising-behaviour part, because I don't think there's a good API change for it that wouldn't either be really clumsy, or be actually less surprising.

@eemeli eemeli closed this as completed Mar 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant