cue icon indicating copy to clipboard operation
cue copied to clipboard

evaluator: `or` function gives structural cycle where or operator does not

Open rogpeppe opened this issue 2 months ago • 1 comments

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

bdc3901b0

Does this issue reproduce with the latest stable release?

Yes

What did you do?

exec cue vet or1.cue
exec cue vet or2.cue

-- or1.cue --
#X: {
	type!: string
	...
}

#X: #A | #B

#A: {
	#X
	type!: "a"
	x?: int
}

#B: {
	#X
	type!: "b"
	y!: int
}
-- or2.cue --
#X: {
	type!: string
	...
}

#X: or([#A, #B])

#A: {
	#X
	type!: "a"
	x?: int
}

#B: {
	#X
	type!: "b"
	y!: int
}

What did you expect to see?

A passing test. In general or([a1, a2]) should behave the same as a1 | a2.

What did you see instead?

> exec cue vet or1.cue
> exec cue vet or2.cue
[stderr]
structural cycle:
    ./or2.cue:6:5
[exit status 1]
FAIL: /tmp/x.txtar:2: unexpected command failure

The or function causes an error where the | operator does not.

rogpeppe avatar Oct 26 '25 09:10 rogpeppe

possibly related to these examples and my other #4182

https://cuelang.org/play/?id=ku0wHtTeEng#w=function&i=cue&f=export&o=cue

https://cuelang.org/play/?id=mkd4MmO5yf4#w=function&i=cue&f=export&o=cue

the-nurk avatar Nov 19 '25 07:11 the-nurk