# Tests that a nested optional field structure combined with let bindings and
# disjunctions (#Output: null | #App) evaluates correctly without false errors.
# https://cuelang.org/issue/3851
-- in.cue --
#App: {
	name?: string
	sub1?: sub2?: null | _
}
#Output: null | #App @test(eq, null | {name?: string, sub1?: {sub2?: null | _}})
out: #Output & {
	name: "foo"
	sub1: sub2: {} | _
	sub1: sub2: {
		sub3: {
			let _let = "bar"
			foo: _let
		}
	}
} @test(eq, {name: "foo", sub1: {sub2: {sub3: {foo: "bar"}}}})
-- out/eval/stats --
Leaks:  8
Freed:  52
Reused: 27
Allocs: 33
Retain: 0

Unifications: 16
Conjuncts:    41
Disjuncts:    14
Notifications: 2

NumCloseIDs: 5
-- out/diff-v2-v3.txt --
Disjunctions with defaults: needs @test(final) for default field selection
v3: sub2 is (#struct); v2: sub2 is (struct)
