cue
cue copied to clipboard
cmd/fmt: comma appended to comment instead of list element
What version of CUE are you using (cue version)?
$ cue version cue version v0.4.1 linux/amd64
What did you do?
I ran cue fmt on a file with a list of inline structs that ends in a comment rather than a value.
bug.cue:
l: [
{},
// comment
]
$ cue fmt bug.cue && cat bug.cue
What did you expect to see?
The input file should not have been changed, as it is correctly formatted.
What did you see instead?
l: [
{}
// comment,
]
If I format that file again, it appends another trailing comma:
l: [
{}
// comment,,
]
I get a new comma each time unless I add a value after the comment.
I'm very new to CUE, but I think this might be related to #1447 based on how both issues seem to interpret the comment as a list element.
Also still exists on v0.4.3 darwin/arm64
Note that this issue is extremely similar to https://github.com/cue-lang/cue/issues/2274, although that issue has an example where fmt's output CUE is invalid.
As of cue v0.6.0 I cannot reproduce this bug
# issue #1478 is not reproducible as of cue v0.6.0---------
exec cat 1478G.cue
exec cue fmt 1478G.cue ### fmt works
exec cat 1478G.cue
exec cue vet 1478G.cue ### vet passes
cmp expected/1478G.cue 1478G.cue
-- 1478G.cue --
l: [
{},
// comment
]
-- expected/1478G.cue --
l: [
{},
// comment
]
Thanks @rudifa! I can confirm the issue appears solved for me as well.