Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

eval: use of list.Contains fails on list derived from comprehension #784

Closed
myitcv opened this issue Feb 20, 2021 · 2 comments
Closed

eval: use of list.Contains fails on list derived from comprehension #784

myitcv opened this issue Feb 20, 2021 · 2 comments

Comments

@myitcv
Copy link
Contributor

myitcv commented Feb 20, 2021

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

$ cue version
cue version +2c86835c linux/amd64

Does this issue reproduce with the latest release?

Yes. Bisected down to 2c86835

What did you do?

exec cue eval working.cue
exec cue eval broken.cue
-- working.cue --
package preguide

import (
	"list"
)

#Guide: {
	Steps: #Command & {
		Terminal: *Terminals[0] | string
	}
	Terminals: [...string]
	ok: true & list.Contains(Terminals, Steps.Terminal)
}

#Command: {
	Terminal: string
}

#Terminal: {
}

g: #Guide & {
	Terminals: ["term1"]
	Steps: #Command
}
-- broken.cue --
package preguide

import (
	"list"
)

#Guide: {
	Steps: #Command & {
		Terminal: *TerminalNames[0] | string
	}
	Terminals: [...string]
	TerminalNames: [ for k in Terminals {k}]
	ok: true & list.Contains(TerminalNames, Steps.Terminal)
}

#Command: {
	Terminal: string
}

#Terminal: {
}

g: #Guide & {
	Terminals: ["term1"]
	Steps: #Command
}

What did you expect to see?

Passing test.

What did you see instead?

> exec cue eval
[stderr]
g.ok: conflicting values false and true:
    ./main.cue:13:6
    ./main.cue:13:13
    ./main.cue:23:4

The difference between working.cue and broken.cue is enough to cause this to break, despite the fact that both are string lists of the same value:

--- working.cue 2021-02-20 05:59:11.159756947 +0000
+++ broken.cue  2021-02-20 05:59:11.159756947 +0000
@@ -6,10 +6,11 @@

 #Guide: {
        Steps: #Command & {
-               Terminal: *Terminals[0] | string
+               Terminal: *TerminalNames[0] | string
        }
        Terminals: [...string]
-       ok: true & list.Contains(Terminals, Steps.Terminal)
+       TerminalNames: [ for k in Terminals {k}]
+       ok: true & list.Contains(TerminalNames, Steps.Terminal)
 }
@myitcv
Copy link
Contributor Author

myitcv commented Feb 20, 2021

FYI - this is not critical to the PWG project. Just noticed in passing (we are in the process of refactoring our schema and can therefore workaround this)

myitcv added a commit to play-with-go/preguide that referenced this issue Feb 20, 2021
With a number of recent changes/improvements in CUE we can greatly
simplify the preguide schema. This also serves as preparation for
changes that will be made as part of #64.

Note this also upgrades to the latest CUE, because this refactored
schema is not susceptible to cuelang/cue#784.

For #115
myitcv added a commit to play-with-go/preguide that referenced this issue Feb 20, 2021
With a number of recent changes/improvements in CUE we can greatly
simplify the preguide schema. This also serves as preparation for
changes that will be made as part of #64.

Note this also upgrades to the latest CUE, because this refactored
schema is not susceptible to cuelang/cue#784.

For #115
myitcv added a commit to play-with-go/preguide that referenced this issue Feb 20, 2021
With a number of recent changes/improvements in CUE we can greatly
simplify the preguide schema. This also serves as preparation for
changes that will be made as part of #64.

Note this also upgrades to the latest CUE, because this refactored
schema is not susceptible to cuelang/cue#784.

For #115
cueckoo pushed a commit that referenced this issue Mar 5, 2021
It is verified that this is the same behavior as v0.2.2.
So this brings v0.3 closer to v0.2.

This also fixes builtins that still relied on the old
behavior.

Fixes #784

Change-Id: I80714da319f91bc09d2d6c3495deaa369d80c9d6
@cueckoo cueckoo closed this as completed in 7326cfa Mar 5, 2021
@cueckoo
Copy link

cueckoo commented Jul 3, 2021

This issue has been migrated to cue-lang/cue#784.

For more details about CUE's migration to a new home, please see cue-lang/cue#1078.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants