# Tests that a definition referencing another definition with a nested pattern
# constraint correctly propagates field constraints through Instance.Fill and
# unification. Issue: filling a field in a closed nested struct failed with
# "field not allowed" when the constraint was inherited via a parent definition
# rather than explicitly re-stated.
# https://cuelang.org/issue/285
-- in.cue --
#TopLevel: [name=string]: {
	path:    string
	content: string
}

#Mid: #TopLevel & {
	myoutput: path: "/output"
} @test(closed) @test(eq, {
	myoutput: {path: "/output", content: string}
})

val: #Mid & {} & {myoutput: {content: "foo"}} @test(closed) @test(eq, {
	myoutput: {content: "foo", path: "/output"}
}) // Should work.
-- out/eval/stats --
Leaks:  0
Freed:  10
Reused: 6
Allocs: 4
Retain: 0

Unifications: 10
Conjuncts:    23
Disjuncts:    10
