# Tests that unifying a disjunction of definitions with an additional constraint
# (#a: (#c | #d) & {name: string}) does not incorrectly reject fields from either branch.
# https://cuelang.org/issue/471
-- in.cue --
package x

#a: (#c | #d) & {
	name: string
}

#a1: #c & {
	name: string
}

#a2: #d & {
	name: string
}

#c: {
	name: string
	age:  int
}

#d: {
	name:    string
	address: string
}

@test(eq, {
	#a: {name: string, age: int} | {name: string, address: string}
	#a1: {name: string, age: int}
	#a2: {name: string, address: string}
	#c: {name: string, age: int}
	#d: {name: string, address: string}
})
-- out/eval/stats --
Leaks:  0
Freed:  21
Reused: 8
Allocs: 13
Retain: 0

Unifications: 17
Conjuncts:    30
Disjuncts:    2

NumCloseIDs: 4
