-
Notifications
You must be signed in to change notification settings - Fork 321
Open
Description
What version of CUE are you using (cue version
)?
17177e96d37f6d504138ff7588cea9157779f687
Does this issue reproduce with the latest stable release?
Yes (v0.13.4)
What did you do?
exec cue vet -c x.cue
-- x.cue --
#Foo: [...] | {
x?: _
if false {}
}
x: #Foo & []
What did you expect to see?
A passing test. The list literal should eliminate the struct from the disjunction.
What did you see instead?
> exec cue vet -c x.cue
[stderr]
x: incomplete value [] | [_]
[exit status 1]
FAIL: /tmp/x.txtar:1: unexpected command failure
This is probably a consequence of the fact that a comprehension counts as embedding a non-struct value, so this is valid, for example:
{
if false {}
} & [1]
Arguably it might be good if a comprehension could not itself change the "scalarness" of a struct, so this would be illegal:
{ if true { 1 } }
requiring an explicit embedded element at the outer level to be considered OK:
{ _, if true { 1 } }
{
if false {}
} & [1]
This behaviour seems unintuitive to me. It would be better if the comprehension was counted as scalar/list only if its possible output value can also be a scalar/list.