# Tests that Fill() followed by Validate(concrete) succeeds for complex disjunction
# definitions under dynamic (interpolated) keys, as it does for static keys.
# https://cuelang.org/issue/342
-- in.cue --
X: {
	#Simple: {
		ref: string
	} @test(shareID=SIMPLE)

	#Complex: {
		{
			ref: string
		} | {
			local: string
		}
	} @test(eq, {ref: string} | {local: string}) @test(shareID=COMPLEX)


	var: "bar"

	// Validate(concrete) after Fill() on Complex.ref from a "static" key will succeed
	"test_1": #Complex @test(shareID=COMPLEX) @test(eq, {
			ref: string
		} | {
			local: string
		})

	// Validate(concrete) after Fill() on "#Simple.ref" from a "dynamic" key will succeed
	"test_2_\(var)": #Simple
	@test(shareID=SIMPLE, at=test_2_bar)
	@test(eq, at=test_2_bar, { ref: string })

	// Validate(concrete) after Fill() on Complex.ref from a "dynamic" key will fail
	"test_3_\(var)": #Complex

	test_3_bar: ref: "FOO"
	@test(eq, at=test_3_bar, { ref: "FOO" })
}

Z: X.test_3_bar.ref @test(eq, "FOO")
-- out/eval/stats --
Leaks:  2
Freed:  18
Reused: 5
Allocs: 15
Retain: 0

Unifications: 14
Conjuncts:    23
Disjuncts:    4

NumCloseIDs: 5
-- out/diff-v2-v3.txt --
Reordering
