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

cmd/cue: def emits invalid output with multiple list conjuncts #1284

Closed
vikstrous2 opened this issue Oct 5, 2021 · 3 comments
Closed

cmd/cue: def emits invalid output with multiple list conjuncts #1284

vikstrous2 opened this issue Oct 5, 2021 · 3 comments

Comments

@vikstrous2
Copy link

What version of CUE are you using (cue version)?

The web based emulator https://cuelang.org/play/#cue@export@yaml

Does this issue reproduce with the latest release?

No, this is a bug reproducible only in the web based emulator.

What did you do?

https://cuelang.org/play/?id=B2-EGA_qicy#cue@export@yaml

l: [...]
l: ["a",...]
l: ["a","b",...]

What did you expect to see?

l: ["a", "b"]

What did you see instead?

When output is set to yaml in the cloud emulator, this produces an error:

failed to encode: l: conflicting values ["a","b",...] and {} (mismatched types list and struct)

Weirdly, this actually works if the list is at the top level (not inside l):

[...]
["a",...]
["a","b",...]

This is a weirdly specific bug. There must be something special about the way the emulator runs. I can't reproduce it locally with any version of cue.

@vikstrous2 vikstrous2 added NeedsInvestigation Triage Requires triage/attention labels Oct 5, 2021
@antong
Copy link
Contributor

antong commented Nov 1, 2021

This is not limited to the playground. I managed a kind of repro with v0.4.0. With the original input, cue def outputs: l: [...] & ["a", ...] & ["a", "b", ...] & {}. So it makes up an extra conjunct "{}" of type struct, which break things. Perhaps the playground does some extra round of cue def, which triggers this.

Here is a txtar/testscript repro with v0.4.0 (@myitcv , did I finally get this right ? ;-)

exec cue def x.cue
stdin stdout
exec cue export -

-- x.cue --
l: [...]
l: ["a",...]
l: ["a","b",...]

Gives:

l: [...] & ["a", ...] & ["a", "b", ...] & {}
> stdin stdout
> exec cue export -
[stderr]
l: conflicting values ["a","b",...] and {} (mismatched types list and struct):
    -:1:25
    -:1:43
[exit status 1]

@myitcv
Copy link
Member

myitcv commented Nov 6, 2021

Here is a txtar/testscript repro with v0.4.0 (@myitcv , did I finally get this right ? ;-)

🎉 great work! Just to check, do you use cmd/testscript to validate them? I tweeted recently about some means by which we could (in an ideal world) have this be integrated as part of the issue tracker/discussions.

This issue really falls in the same bucket as #1340, but will keep separate for now because I'm not totally clear they are one and the same "issue".

@myitcv myitcv changed the title conflicting values when rendering list in object in cuelang.org/play cmd/cue: def emits invalid output with multiple list conjuncts Nov 6, 2021
@myitcv myitcv added NeedsFix and removed NeedsInvestigation Triage Requires triage/attention labels Nov 6, 2021
@antong
Copy link
Contributor

antong commented Nov 6, 2021

Just to check, do you use cmd/testscript to validate them?

I installed github.com/rogpeppe/go-internal/cmd/testscript, ran it, and fed it the input (txtar). Then I copy pasted the interesting part from the output to the comment/description.

@mpvl mpvl added this to the v0.4.1: bug fixes milestone Nov 19, 2021
cueckoo pushed a commit that referenced this issue Nov 22, 2021
Fixes bug where a temporary struct was added even if the
underlying value itself was not a struct.

Fixes #1284

Signed-off-by: Marcel van Lohuizen <[email protected]>

Change-Id: I29c615c4670594d00725dd54e13ca96b3b33e304
Signed-off-by: Marcel van Lohuizen <[email protected]>
cueckoo pushed a commit that referenced this issue Nov 23, 2021
Fixes bug where a temporary struct was added even if the
underlying value itself was not a struct.

Fixes #1284

Signed-off-by: Marcel van Lohuizen <[email protected]>

Change-Id: I29c615c4670594d00725dd54e13ca96b3b33e304
Signed-off-by: Marcel van Lohuizen <[email protected]>
cueckoo pushed a commit that referenced this issue Nov 23, 2021
Fixes bug where a temporary struct was added even if the
underlying value itself was not a struct.

Fixes #1284

Signed-off-by: Marcel van Lohuizen <[email protected]>

Change-Id: I29c615c4670594d00725dd54e13ca96b3b33e304
Signed-off-by: Marcel van Lohuizen <[email protected]>
jlongtine pushed a commit to jlongtine/cue that referenced this issue Dec 8, 2021
Fixes bug where a temporary struct was added even if the
underlying value itself was not a struct.

Fixes cue-lang#1284

Signed-off-by: Marcel van Lohuizen <[email protected]>

Change-Id: I29c615c4670594d00725dd54e13ca96b3b33e304
Signed-off-by: Marcel van Lohuizen <[email protected]>
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/527841
Unity-Result: CUEcueckoo <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
Reviewed-by: Paul Jolly <[email protected]>
Signed-off-by: Joel Longtine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants