-
Notifications
You must be signed in to change notification settings - Fork 331
internal/encoding/yaml: encode YAML anchors as CUE definitions #3987
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
base: master
Are you sure you want to change the base?
Conversation
If recursive anchors like that no longer fail, what CUE do they result in? |
You can see in the error above:
Still recursive, so it's invalid. But the encoder doesn't recurse infinitely. |
Ah I see. That's fine; I don't imagine these cases will actually show up in practice often. Indeed I think we avoided cycles because of endless recursion. |
On the one hand it makes no sense to emit an invalid CUE file. |
Fine, then I'll edit the test. |
d914607
to
80c4fa0
Compare
0e46f6f
to
add7dce
Compare
I pushed some changes to make the tests pass. |
add7dce
to
33cc9e0
Compare
Alright, that should be sorted. Had a positioning issue where I accidentally called |
@OmriSteiner the tests are failing, not sure if you saw that? |
Yes, I did.
I only pushed the additional commit for you to look at. If you think this is worth the tradeoff with implementation complexity, then I can fix the tests. Otherwise I think it's better if I remove the last commit here (and then the tests pass). |
Ah, I had misunderstood. And apologies for the slowness. Yes, I think your latest commit is a perfectly fine approach. If you can fix the tests, I'll do a final review :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking as "request changes" as a reminder to myself that this needs CI to be fixed before I review again.
This commits supports encoding YAML documents such as: a: &a 3 b: *a To this CUE document: #a: 3 a: #a b: #a Fixes cue-lang#3818 Signed-off-by: Omri Steiner <[email protected]>
…re they're defined Signed-off-by: Omri Steiner <[email protected]>
4a3b889
to
84379d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
importing into Gerrit here: https://cue.gerrithub.io/c/cue-lang/cue/+/1223900 I tweaked the commit message a bit as well, assuming that's okay with you. |
@rogpeppe correctly spotted that the use of definitions breaks valid use cases today, so I need to take a closer look. See the Gerrit patch discussion. |
Fixes #3818
There's one small issue open to handle. Tests are currently failing with:
I could change the code to match the old behavior of rejecting such YAML documents, since the resulting CUE document is invalid.
However, I think the original reason we error out for such document was that it would lead to endless recursion in the parser. This is no longer the case, so I'm debating whether the correct fix would be to error out, or change the test.