# Tests that list comprehensions work correctly when iterating over lists with
# default values (disjunctions using *). Issue #507: comprehensions over
# [...T] | *[elem] lists failed with "invalid operand" errors.
# https://cuelang.org/issue/507
-- in.cue --
package x

somelist: [...string] | *[]
// Works just fine
foo: [
	for e in somelist {
		"hello foo: \(e)"
	},
] @test(eq, [])

otherlist: ["something"] @test(eq, ["something"])
// Works fine as well
z: [
	for e in otherlist {
		"hello z: \(e)"
	},
] @test(eq, ["hello z: something"])

extlist: [...string] | *["something"]
bar: [
	for e in extlist {
		"hello bar: \(e)"
	},
] @test(eq, ["hello bar: something"])
-- out/eval/stats --
Leaks:  0
Freed:  15
Reused: 5
Allocs: 10
Retain: 0

Unifications: 11
Conjuncts:    17
Disjuncts:    4

NumCloseIDs: 4
