// Issue #852

-- in.cue --
#E: {
	c: int
}
#A: {
	b: int
	q: {
		#E
		d: int
	}
}
a: #A & {
	b: 3
	q: {
		c: 2
		e: 43
	}
}

// `a` is evaluated through the comprehension first. Ensure that
// this does not bypass closedness checks.
issue852: {
	#A: {
		[=~"^a-z$"]: string
	}

	a: #A

	a: Foo: "foo"

	for k, v in a {
		b: "\(k)": v
	}
}

dynamic: {
	#D: {
		key:   "foo"
		(key): int
	}
	d: #D & {foo: 3}
}
-- embed.cue --
issue3325: ok: {
	#Items: [Name=string]: {
		name: Name
	}

	#Base: {
		name: "base"
		type: string

		items: #Items
	}

	#Extended: #Base & {
		type: "extended"
		items: "my-item": {}
	}

	broken: {
		#Base
		#Extended
	}

	works: {
		#Extended
		#Base
	}
}

patterns: shallow: {
	#a: [>="k"]: int
	#b: [<="m"]: int
	#c: [>="w"]: int
	#d: [<="y"]: int

	single: {
		X: #a // "k" <= x
		err: X
		err: j: 3

		ok: X
		ok: k: 3
	}

	and: p1: {
		X: #a & #b // "k" <= x && x <= "m"

		err: X
		err: j: 3

		ok: X
		ok: k: 3
	}

	and: p2: {
		X: #b & #a // "k" <= x && x <= "m"
		err: X
		err: j: 3

		ok: X
		ok: k: 3
	}

	andEmbed: p1: {
		X: { #a & #b } // "k" <= x && x <= "m"

		err: X
		err: j: 3

		ok: X
		ok: k: 3
	}

	andEmbed: p2: {
		X: { #b & #a } // "k" <= x && x <= "m"
		err: X
		err: j: 3

		ok: X
		ok: k: 3
	}

	orEmbed: p1: {
		X: { #a, #b } // "k" <= x && x <= "m"

		ok1: X
		ok1: j: 3

		ok2: X
		ok2: k: 3
	}

	orEmbed: p2: {
		X: { #b, #a } // "k" <= x && x <= "m"
		ok1: X
		ok1: j: 3

		ok2: X
		ok2: k: 3
	}

	andOrEmbed: t1: p1: {
		// ("k" <= x && x <= "m")  || ("w" <= x && x <= "y")
		X: {
			#a & #b
			#c & #d
		}
		err1: X
		err1: j: 3

		ok1: X
		ok1: k: 3
	}

	andOrEmbed: t1: p2: {
		// ("k" <= x && x <= "m")  || ("w" <= x && x <= "y")
		X: {
			#c & #d
			#a & #b
		}
		err1: X
		err1: j: 3

		ok1: X
		ok1: k: 3
	}

	andOrEmbed: t2:{
		// ("k" <= x && x <= "m")  || ("w" <= x && x <= "y") || x == "p"
		X: {
			#a & #b
			#c & #d
			["p"]: int
		}
		err1: X
		err1: j: 3

		ok1: X
		ok1: k: 3

		ok2: X
		ok2: p: 3
	}

	// The last indirection is not a definition.
	indirect: {
		a: [>="k"]: int
		#a: a

		p1: { // XXX // link to code
			X: #a
			err1: X
			err1: j: 3

			err2: X & __no_sharing
			err2: j: 3

			ok: X
			ok:k: 3
		}

		p2: {
			#a: a & __no_sharing
			X: #a

			err1: X
			err1: j: 3

			err2: X & __no_sharing
			err2: j: 3

			ok: X
			ok: k: 3
		}

		p3: {
			X: #a & __no_sharing

			err1: X
			err1: j: 3

			err2: X & __no_sharing
			err2: j: 3

			ok: X
			ok: k: 3
		}

		p4: {
			#a: a & __no_sharing
			X: #a
			X: #a & __no_sharing

			err1: X
			err1: j: 3

			err2: X & __no_sharing
			err2: j: 3

			ok: X
			ok: k: 3
		}
	}
}

patterns: nested: {
	#a: x: y: [>="k"]: int
	#b: x: y: [<="m"]: int
	#c: x: y: [>="w"]: int
	#d: x: y: [<="y"]: int

	single: {
		X: #a // "k" <= x
		err: X
		err: x: y: j: 3

		ok: X
		ok: x: y: k: 3
	}

	and: p1: {
		X: #a & #b // "k" <= x && x <= "m"

		err: X
		err: x: y: j: 3

		ok: X
		ok: x: y: k: 3
	}

	and: p2: {
		X: #b & #a // "k" <= x && x <= "m"
		err: X
		err: x: y: j: 3

		ok: X
		ok: x: y: k: 3
	}

	andEmbed: p1: {
		X: { #a & #b } // "k" <= x && x <= "m"

		err: X
		err: x: y: j: 3

		ok: X
		ok: x: y: k: 3
	}

	andEmbed: p2: {
		X: { #b & #a } // "k" <= x && x <= "m"
		err: X
		err: x: y: j: 3

		ok: X
		ok: x: y: k: 3
	}

	orEmbed: p1: {
		X: { #a, #b } // "k" <= x && x <= "m"

		ok1: X
		ok1: x: y: j: 3

		ok2: X
		ok2: x: y: k: 3
	}

	orEmbed: p2: {
		X: { #b, #a } // "k" <= x && x <= "m"
		ok1: X
		ok1: x: y: j: 3

		ok2: X
		ok2: x: y: k: 3
	}

	andOrEmbed: t1: p1: {
		// ("k" <= x && x <= "m")  || ("w" <= x && x <= "y")
		X: {
			#a & #b
			#c & #d
		}
		err1: X
		err1: x: y: j: 3

		ok1: X
		ok1: x: y: k: 3
	}

	andOrEmbed: t1: p2: {
		// ("k" <= x && x <= "m")  || ("w" <= x && x <= "y")
		X: {
			#c & #d
			#a & #b
		}
		err1: X
		err1: x: y: j: 3

		ok1: X
		ok1: x: y: k: 3
	}

	andOrEmbed: t2:{
		// ("k" <= x && x <= "m")  || ("w" <= x && x <= "y") || x == "p"
		X: {
			#a & #b
			#c & #d
			["p"]: int
		}
		err1: X
		err1: x: y: j: 3

		ok1: X
		ok1: x: y: k: 3

		ok2: X
		ok2: x: y: p: 3
	}

	// The last indirection is not a definition.
	indirect: {
		a: x: y: [>="k"]: int
		#a: a

		p1: {
			X: #a
			err1: X
			err1: x: y: j: 3

			err2: X & __no_sharing
			err2: x: y: j: 3

			ok: X
			ok: x: y: k: 3
		}

		p2: {
			#a: a & __no_sharing
			X: #a

			err1: X
			err1: x: y: j: 3

			err2: X & __no_sharing
			err2: x: y: j: 3

			ok: X
			ok: x: y: k: 3
		}

		p3: {
			X: #a & __no_sharing

			err1: X
			err1: x: y: j: 3

			err2: X & __no_sharing
			err2: x: y: j: 3

			ok: X
			ok: x: y: k: 3
		}

		p4: {
			#a: a & __no_sharing
			X: #a
			X: #a & __no_sharing

			err1: X
			err1: x: y: j: 3

			err2: X & __no_sharing
			err2: x: y: j: 3

			ok: X
			ok: x: y: k: 3
		}
	}
}

issue2241: {
	#close: {}

	a: {
	    x: q: 2
	    #close
	}

	b: a
	b: x: r: 4
}

-- ellipsis.cue --
issue3778: full: {
	#x: a?: string
	#y: #x & { ... }
	z: #y & {
		a: "ok"
		b: "something"
	}
}
issue3778: keepOpen: {
	#x: { a?: string, ... }
	#y: #x & { ... }
	z: #y & {
		a: "ok"
		b: "something"
	}
}

// All three reproducers below should fail with "field not allowed".
issue1867: one: {
	#T: close({})
	#T: {...}
	x: #T
	x: foo: "foo"
}
issue1867: two: {
	#S: {}
	#T: s: #S
	#T: s: {...}
	x: #T.s
	x: foo: "foo"
}
// This third version used to not fail as expected on evalv2.
issue1867: three: {
	#T: s: close({})
	#T: s: {...}
	x: #T.s
	x: foo: "foo"
}
issue3924: one: {
	#Schema: {
		...
		{[string]: #SchemaInner}
	}
	#SchemaInner: allowed?: string

	out: #Schema & {foo: disallowed: "foo"} // should fail
}
issue3924: two: {
	#Schema: {
		{[string]: #job}

		#job: matchN(1, [{
			other?: string
			...
		}]) & close({
			allowed?: string
		})
	}
	out: #Schema & {foo: disallowed: "bar"} // should fail
}

-- reroot.cue --
import "list"

issue3330: {
	let: ok: {
		#struct: {
			let empty = {}

			field: null | { n: int }
			field: empty & { n: 3 }
		}

		out: list.Concat([[#struct]])
	}
	matthew: ok1: {
		#struct: {
			field: { n: 3 } & g
			g: {}
		}

		out: #struct & {}
	}
	matthew: ok2: {
		#struct: {
			field: { n: 3 } & g
			g: {}
		}

		out: #struct
		out2: out & {}
	}
}
issue3331: {
	original: ok: {
		#A: {
			let b = {}
			c: b & {
				d: 1
			}
		}
		list.Concat([[#A]])
	}
	variant1: ok: {
		#A: {
			let b = {}
			c: b & {
				d: 1
			}
		}
		[[#A]]
	}
}

// indirect tests cases where a reference indirectly crosses a node that
// references a definition, thereby indirectly referencing it.
indirect: {
	embed: err1: {
		#A: {
			x: {#x, #y}
			zx: x.a
		}

		#x: {a: b: 1}
		#y: {a: c: 2}

		b: #A

		b1: b.zx
		b1: d: 1 // This should fail as b.zx crosses a reference to definition.
	}
	closed: err1: {
		X: {
			// refer to a value that will be closed after unification in another struct.
			a: b
			b: {}
			a: e: 1
		}
		Y: X
		Y: {
			b: c
			c: #X
		}
		#X: {}
	}
}
// nested.a
nested: ok1: {
	#A: {
	b: {}

	#B: {
		c: b & {
			d: 1
			}
		}
	}
	x: #A
}
nested: embed: ok: {
	x: #A
	#A: {
		k
	}
	k: {
		d: b & {e: int}
		b: {}
	}
}
// nested.b tests insertion of a field (b) that has a conjunct rooted within
// the tree it is referred in as well as a conjunct outside of it that refers
// to a definition.
nested: err1: {
	x: #A
	#A: {
		b: f: 1
		v: #V
		#V: {
			c: b & { // Fails as #B is not compatible.
				d: 1
			}
		}
	}
	x: b: #B
	#B: g: 1
}

nested: err2: {
	#A: {
		b: {} // error only reported here.
		c: b & {
			// error (g not allowed) not reported here, as it would be okay if b
			// were valid. Instead, it is reported at b only. This is conform
			// the spec.
			d: 1
		}
	}
	x: #A
	x: b: g: 1
}

inline: {
	#x: y: z?: name: string

	err1: (#x & {y: z: _}).y.z & {
		name: "a"
		age1: 5 // not allowed
	}
	err2: (#x.y & {z: _}).z & {
		name: "a"
		age2: 5 // not allowed
	}
}

// minInDef defines examples where a definition is mixed into an open struct,
// where then this struct refers to a field that is closed by the definition.
mixInDef: {
	refInside: {
		#x: b: c: {d: {}, e: f: {} }
		a: #x
		a: b: c: d: {}
		a: b: c: e: c.d
	}
	refEdge: {
		#x: c: {d: {}, e: f: {} }
		a: #x
		a: c: d: {}
		a: c: e: c.d
	}
	refOutside: {
		#x: c: {d: {}, e: f: {} }
		a: #x
		a: c: d: {}
		a: c: e: a.c.d // crosses definition
	}
}

issue3601: original: {
	out: {
		#Transform.output
	}
	#Transform: output: (#Patch & {}).output
	#Patch: {
		target: {}
		output: foo: {
			final: target
			final: version: "v1"
		}
	}
}
issue3601: originalNoShare: {
	// Like the original, but with explicit no sharing.
	out: {
		#Transform.output
	}
	#Transform: output: (#Patch & __no_sharing).output
	#Patch: {
		target: {}
		output: foo: {
			final: target
			final: version: "v1"
		}
	}
}
issue3601: reduced: {
	#X: {
		a: b: c: "v1"
		a: b: empty
		empty: {}
	}

	original: {
		Y: (#X & __no_sharing).a
		out: Y & __no_sharing
	}
	moreInlining: {
		out: (#X & {}).a & {}
	}
	noInline: {
		Y: #X & __no_sharing
		Z: Y & __no_sharing
		out: Z.a & __no_sharing
	}
	moreNesting: {
		#X: {
			a: b: c: d: "v1"
			a: b: c: empty
			empty: {}
		}
		Y: (#X.a & __no_sharing).b
		Z: Y & __no_sharing
	}
}

-- validation.cue --
import "list"

issue3332: {
	#def: field: list.MinItems(1)
	use: #def & {
	  field: ["value"]
	}
}

-- out/evalalpha/stats --
Leaks:  989
Freed:  0
Reused: 0
Allocs: 989
Retain: 0

Unifications: 960
Conjuncts:    2064
Disjuncts:    2

CloseIDElems: 4777
NumCloseIDs: 699
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
diff old new
--- old
+++ new
@@ -1,9 +1,12 @@
-Leaks:  21
-Freed:  828
-Reused: 820
-Allocs: 29
-Retain: 89
-
-Unifications: 843
-Conjuncts:    2097
-Disjuncts:    918
+Leaks:  989
+Freed:  0
+Reused: 0
+Allocs: 989
+Retain: 0
+
+Unifications: 960
+Conjuncts:    2064
+Disjuncts:    2
+
+CloseIDElems: 4777
+NumCloseIDs: 699
-- out/eval/stats --
Leaks:  21
Freed:  828
Reused: 820
Allocs: 29
Retain: 89

Unifications: 843
Conjuncts:    2097
Disjuncts:    918
-- out/eval --
Errors:
a.q.e: field not allowed:
    ./in.cue:1:5
    ./in.cue:6:5
    ./in.cue:7:3
    ./in.cue:11:4
    ./in.cue:15:3
indirect.closed.err1.Y.a.e: field not allowed:
    ./reroot.cue:73:7
    ./reroot.cue:74:7
    ./reroot.cue:75:7
    ./reroot.cue:77:6
    ./reroot.cue:79:7
    ./reroot.cue:80:7
    ./reroot.cue:82:7
issue1867.one.x.foo: field not allowed:
    ./ellipsis.cue:20:12
    ./ellipsis.cue:21:7
    ./ellipsis.cue:22:5
    ./ellipsis.cue:23:5
issue1867.three.x.foo: field not allowed:
    ./ellipsis.cue:34:15
    ./ellipsis.cue:35:10
    ./ellipsis.cue:36:5
    ./ellipsis.cue:37:5
issue1867.two.x.foo: field not allowed:
    ./ellipsis.cue:26:6
    ./ellipsis.cue:27:9
    ./ellipsis.cue:28:10
    ./ellipsis.cue:29:5
    ./ellipsis.cue:30:5
issue3778.full.z.b: field not allowed:
    ./ellipsis.cue:2:6
    ./ellipsis.cue:3:6
    ./ellipsis.cue:3:13
    ./ellipsis.cue:4:5
    ./ellipsis.cue:6:3
issue3924.one.out.foo.disallowed: field not allowed:
    ./ellipsis.cue:42:3
    ./ellipsis.cue:42:14
    ./ellipsis.cue:44:16
    ./ellipsis.cue:46:7
    ./ellipsis.cue:46:23
issue852.a.Foo: field not allowed:
    ./in.cue:22:6
    ./in.cue:26:5
    ./in.cue:28:5
nested.err1.x.#V.c.d: field not allowed:
    ./reroot.cue:112:5
    ./reroot.cue:114:6
    ./reroot.cue:117:7
    ./reroot.cue:118:5
    ./reroot.cue:122:8
    ./reroot.cue:123:6
nested.err1.x.#V.c.f: field not allowed:
    ./reroot.cue:112:5
    ./reroot.cue:114:6
    ./reroot.cue:117:7
    ./reroot.cue:117:11
    ./reroot.cue:122:8
    ./reroot.cue:123:6
nested.err1.x.b.f: field not allowed:
    ./reroot.cue:112:5
    ./reroot.cue:114:6
    ./reroot.cue:122:8
    ./reroot.cue:123:6
nested.err1.x.b.g: field not allowed:
    ./reroot.cue:112:5
    ./reroot.cue:114:6
    ./reroot.cue:122:8
    ./reroot.cue:123:6
nested.err1.x.v.c.d: field not allowed:
    ./reroot.cue:112:5
    ./reroot.cue:114:6
    ./reroot.cue:115:6
    ./reroot.cue:117:7
    ./reroot.cue:118:5
    ./reroot.cue:122:8
    ./reroot.cue:123:6
nested.err1.x.v.c.f: field not allowed:
    ./reroot.cue:112:5
    ./reroot.cue:114:6
    ./reroot.cue:115:6
    ./reroot.cue:117:7
    ./reroot.cue:117:11
    ./reroot.cue:122:8
    ./reroot.cue:123:6
nested.err2.x.b.g: field not allowed:
    ./reroot.cue:128:6
    ./reroot.cue:136:5
    ./reroot.cue:137:8
patterns.nested.and.p1.err.x.y.j: field not allowed:
    ./embed.cue:206:12
    ./embed.cue:207:12
    ./embed.cue:221:6
    ./embed.cue:221:11
    ./embed.cue:223:8
    ./embed.cue:224:14
patterns.nested.and.p2.err.x.y.j: field not allowed:
    ./embed.cue:206:12
    ./embed.cue:207:12
    ./embed.cue:231:6
    ./embed.cue:231:11
    ./embed.cue:232:8
    ./embed.cue:233:14
patterns.nested.andEmbed.p1.err.x.y.j: field not allowed:
    ./embed.cue:206:12
    ./embed.cue:207:12
    ./embed.cue:240:8
    ./embed.cue:240:13
    ./embed.cue:242:8
    ./embed.cue:243:14
patterns.nested.andEmbed.p2.err.x.y.j: field not allowed:
    ./embed.cue:206:12
    ./embed.cue:207:12
    ./embed.cue:250:8
    ./embed.cue:250:13
    ./embed.cue:251:8
    ./embed.cue:252:14
patterns.nested.andOrEmbed.t1.p1.err1.x.y.j: field not allowed:
    ./embed.cue:206:12
    ./embed.cue:207:12
    ./embed.cue:208:12
    ./embed.cue:209:12
    ./embed.cue:280:4
    ./embed.cue:280:9
    ./embed.cue:281:4
    ./embed.cue:281:9
    ./embed.cue:283:9
    ./embed.cue:284:15
patterns.nested.andOrEmbed.t1.p2.err1.x.y.j: field not allowed:
    ./embed.cue:206:12
    ./embed.cue:207:12
    ./embed.cue:208:12
    ./embed.cue:209:12
    ./embed.cue:293:4
    ./embed.cue:293:9
    ./embed.cue:294:4
    ./embed.cue:294:9
    ./embed.cue:296:9
    ./embed.cue:297:15
patterns.nested.andOrEmbed.t2.err1.x.y.j: field not allowed:
    ./embed.cue:206:12
    ./embed.cue:207:12
    ./embed.cue:208:12
    ./embed.cue:209:12
    ./embed.cue:306:4
    ./embed.cue:306:9
    ./embed.cue:307:4
    ./embed.cue:307:9
    ./embed.cue:310:9
    ./embed.cue:311:15
patterns.nested.andOrEmbed.t2.ok2.x.y.p: field not allowed:
    ./embed.cue:206:12
    ./embed.cue:207:12
    ./embed.cue:208:12
    ./embed.cue:209:12
    ./embed.cue:306:4
    ./embed.cue:306:9
    ./embed.cue:307:4
    ./embed.cue:307:9
    ./embed.cue:316:8
    ./embed.cue:317:14
patterns.nested.indirect.p1.err1.x.y.j: field not allowed:
    ./embed.cue:322:12
    ./embed.cue:323:7
    ./embed.cue:326:7
    ./embed.cue:327:10
    ./embed.cue:328:16
patterns.nested.indirect.p1.err2.x.y.j: field not allowed:
    ./embed.cue:322:12
    ./embed.cue:323:7
    ./embed.cue:326:7
    ./embed.cue:330:10
    ./embed.cue:331:16
patterns.nested.indirect.p2.err1.x.y.j: field not allowed:
    ./embed.cue:322:12
    ./embed.cue:338:8
    ./embed.cue:339:7
    ./embed.cue:341:10
    ./embed.cue:342:16
patterns.nested.indirect.p2.err2.x.y.j: field not allowed:
    ./embed.cue:322:12
    ./embed.cue:338:8
    ./embed.cue:339:7
    ./embed.cue:344:10
    ./embed.cue:345:16
patterns.nested.indirect.p3.err1.x.y.j: field not allowed:
    ./embed.cue:322:12
    ./embed.cue:323:7
    ./embed.cue:352:7
    ./embed.cue:354:10
    ./embed.cue:355:16
patterns.nested.indirect.p3.err2.x.y.j: field not allowed:
    ./embed.cue:322:12
    ./embed.cue:323:7
    ./embed.cue:352:7
    ./embed.cue:357:10
    ./embed.cue:358:16
patterns.nested.indirect.p4.err1.x.y.j: field not allowed:
    ./embed.cue:322:12
    ./embed.cue:365:8
    ./embed.cue:366:7
    ./embed.cue:369:10
    ./embed.cue:370:16
patterns.nested.indirect.p4.err2.x.y.j: field not allowed:
    ./embed.cue:322:12
    ./embed.cue:365:8
    ./embed.cue:366:7
    ./embed.cue:372:10
    ./embed.cue:373:16
patterns.nested.single.err.x.y.j: field not allowed:
    ./embed.cue:206:12
    ./embed.cue:212:6
    ./embed.cue:213:8
    ./embed.cue:214:14
patterns.shallow.and.p1.err.j: field not allowed:
    ./embed.cue:30:6
    ./embed.cue:31:6
    ./embed.cue:45:6
    ./embed.cue:45:11
    ./embed.cue:47:8
    ./embed.cue:48:8
patterns.shallow.and.p2.err.j: field not allowed:
    ./embed.cue:30:6
    ./embed.cue:31:6
    ./embed.cue:55:6
    ./embed.cue:55:11
    ./embed.cue:56:8
    ./embed.cue:57:8
patterns.shallow.andEmbed.p1.err.j: field not allowed:
    ./embed.cue:30:6
    ./embed.cue:31:6
    ./embed.cue:64:6
    ./embed.cue:64:8
    ./embed.cue:64:13
    ./embed.cue:66:8
    ./embed.cue:67:8
patterns.shallow.andEmbed.p2.err.j: field not allowed:
    ./embed.cue:30:6
    ./embed.cue:31:6
    ./embed.cue:74:6
    ./embed.cue:74:8
    ./embed.cue:74:13
    ./embed.cue:75:8
    ./embed.cue:76:8
patterns.shallow.andOrEmbed.t1.p1.err1.j: field not allowed:
    ./embed.cue:30:6
    ./embed.cue:31:6
    ./embed.cue:32:6
    ./embed.cue:33:6
    ./embed.cue:103:6
    ./embed.cue:104:4
    ./embed.cue:104:9
    ./embed.cue:105:4
    ./embed.cue:105:9
    ./embed.cue:107:9
    ./embed.cue:108:9
patterns.shallow.andOrEmbed.t1.p2.err1.j: field not allowed:
    ./embed.cue:30:6
    ./embed.cue:31:6
    ./embed.cue:32:6
    ./embed.cue:33:6
    ./embed.cue:116:6
    ./embed.cue:117:4
    ./embed.cue:117:9
    ./embed.cue:118:4
    ./embed.cue:118:9
    ./embed.cue:120:9
    ./embed.cue:121:9
patterns.shallow.andOrEmbed.t2.err1.j: field not allowed:
    ./embed.cue:30:6
    ./embed.cue:31:6
    ./embed.cue:32:6
    ./embed.cue:33:6
    ./embed.cue:129:6
    ./embed.cue:130:4
    ./embed.cue:130:9
    ./embed.cue:131:4
    ./embed.cue:131:9
    ./embed.cue:134:9
    ./embed.cue:135:9
patterns.shallow.indirect.p1.err1.j: field not allowed:
    ./embed.cue:146:6
    ./embed.cue:147:7
    ./embed.cue:150:7
    ./embed.cue:151:10
    ./embed.cue:152:10
patterns.shallow.indirect.p1.err2.j: field not allowed:
    ./embed.cue:146:6
    ./embed.cue:147:7
    ./embed.cue:150:7
    ./embed.cue:154:10
    ./embed.cue:155:10
patterns.shallow.indirect.p2.err1.j: field not allowed:
    ./embed.cue:146:6
    ./embed.cue:162:8
    ./embed.cue:163:7
    ./embed.cue:165:10
    ./embed.cue:166:10
patterns.shallow.indirect.p2.err2.j: field not allowed:
    ./embed.cue:146:6
    ./embed.cue:162:8
    ./embed.cue:163:7
    ./embed.cue:168:10
    ./embed.cue:169:10
patterns.shallow.indirect.p3.err1.j: field not allowed:
    ./embed.cue:146:6
    ./embed.cue:147:7
    ./embed.cue:176:7
    ./embed.cue:178:10
    ./embed.cue:179:10
patterns.shallow.indirect.p3.err2.j: field not allowed:
    ./embed.cue:146:6
    ./embed.cue:147:7
    ./embed.cue:176:7
    ./embed.cue:181:10
    ./embed.cue:182:10
patterns.shallow.indirect.p4.err1.j: field not allowed:
    ./embed.cue:146:6
    ./embed.cue:189:8
    ./embed.cue:190:7
    ./embed.cue:193:10
    ./embed.cue:194:10
patterns.shallow.indirect.p4.err2.j: field not allowed:
    ./embed.cue:146:6
    ./embed.cue:189:8
    ./embed.cue:190:7
    ./embed.cue:196:10
    ./embed.cue:197:10
patterns.shallow.single.err.j: field not allowed:
    ./embed.cue:30:6
    ./embed.cue:36:6
    ./embed.cue:37:8
    ./embed.cue:38:8
issue3924.two.out.foo: invalid value {disallowed:_|_(issue3924.two.out.foo.disallowed: field not allowed),allowed?:string} (does not satisfy matchN): 0 matched, expected 1:
    ./ellipsis.cue:52:9
    ./ellipsis.cue:50:14
    ./ellipsis.cue:52:16
    ./ellipsis.cue:59:23
issue3924.two.out.foo.disallowed: field not allowed:
    ./ellipsis.cue:52:9
    ./ellipsis.cue:50:3
    ./ellipsis.cue:50:14
    ./ellipsis.cue:55:15
    ./ellipsis.cue:59:7
    ./ellipsis.cue:59:23

Result:
(_|_){
  // [eval]
  issue3778: (_|_){
    // [eval]
    full: (_|_){
      // [eval]
      #x: (#struct){
        a?: (string){ string }
      }
      #y: (#struct){
        a?: (string){ string }
      }
      z: (_|_){
        // [eval]
        a: (string){ "ok" }
        b: (_|_){
          // [eval] issue3778.full.z.b: field not allowed:
          //     ./ellipsis.cue:2:6
          //     ./ellipsis.cue:3:6
          //     ./ellipsis.cue:3:13
          //     ./ellipsis.cue:4:5
          //     ./ellipsis.cue:6:3
        }
      }
    }
    keepOpen: (struct){
      #x: (#struct){
        a?: (string){ string }
      }
      #y: (#struct){
        a?: (string){ string }
      }
      z: (#struct){
        a: (string){ "ok" }
        b: (string){ "something" }
      }
    }
  }
  issue1867: (_|_){
    // [eval]
    one: (_|_){
      // [eval]
      #T: (#struct){
      }
      x: (_|_){
        // [eval]
        foo: (_|_){
          // [eval] issue1867.one.x.foo: field not allowed:
          //     ./ellipsis.cue:20:12
          //     ./ellipsis.cue:21:7
          //     ./ellipsis.cue:22:5
          //     ./ellipsis.cue:23:5
        }
      }
    }
    two: (_|_){
      // [eval]
      #S: (#struct){
      }
      #T: (#struct){
        s: (#struct){
        }
      }
      x: (_|_){
        // [eval]
        foo: (_|_){
          // [eval] issue1867.two.x.foo: field not allowed:
          //     ./ellipsis.cue:26:6
          //     ./ellipsis.cue:27:9
          //     ./ellipsis.cue:28:10
          //     ./ellipsis.cue:29:5
          //     ./ellipsis.cue:30:5
        }
      }
    }
    three: (_|_){
      // [eval]
      #T: (#struct){
        s: (#struct){
        }
      }
      x: (_|_){
        // [eval]
        foo: (_|_){
          // [eval] issue1867.three.x.foo: field not allowed:
          //     ./ellipsis.cue:34:15
          //     ./ellipsis.cue:35:10
          //     ./ellipsis.cue:36:5
          //     ./ellipsis.cue:37:5
        }
      }
    }
  }
  issue3924: (_|_){
    // [eval]
    one: (_|_){
      // [eval]
      #Schema: (#struct){
      }
      #SchemaInner: (#struct){
        allowed?: (string){ string }
      }
      out: (_|_){
        // [eval]
        foo: (_|_){
          // [eval]
          disallowed: (_|_){
            // [eval] issue3924.one.out.foo.disallowed: field not allowed:
            //     ./ellipsis.cue:42:3
            //     ./ellipsis.cue:42:14
            //     ./ellipsis.cue:44:16
            //     ./ellipsis.cue:46:7
            //     ./ellipsis.cue:46:23
          }
          allowed?: (string){ string }
        }
      }
    }
    two: (_|_){
      // [eval]
      #Schema: (#struct){
        #job: (#struct){
          allowed?: (string){ string }
        }
      }
      out: (_|_){
        // [eval]
        #job: (#struct){
          allowed?: (string){ string }
        }
        foo: (_|_){
          // [eval] issue3924.two.out.foo: invalid value {disallowed:_|_(issue3924.two.out.foo.disallowed: field not allowed),allowed?:string} (does not satisfy matchN): 0 matched, expected 1:
          //     ./ellipsis.cue:52:9
          //     ./ellipsis.cue:50:14
          //     ./ellipsis.cue:52:16
          //     ./ellipsis.cue:59:23
          // issue3924.two.out.foo.disallowed: field not allowed:
          //     ./ellipsis.cue:52:9
          //     ./ellipsis.cue:50:3
          //     ./ellipsis.cue:50:14
          //     ./ellipsis.cue:55:15
          //     ./ellipsis.cue:59:7
          //     ./ellipsis.cue:59:23
          disallowed: (_|_){
            // [eval] issue3924.two.out.foo.disallowed: field not allowed:
            //     ./ellipsis.cue:52:9
            //     ./ellipsis.cue:50:3
            //     ./ellipsis.cue:50:14
            //     ./ellipsis.cue:55:15
            //     ./ellipsis.cue:59:7
            //     ./ellipsis.cue:59:23
          }
          allowed?: (string){ string }
        }
      }
    }
  }
  issue3325: (struct){
    ok: (struct){
      #Items: (#struct){
      }
      #Base: (#struct){
        name: (string){ "base" }
        type: (string){ string }
        items: (#struct){
        }
      }
      #Extended: (#struct){
        name: (string){ "base" }
        type: (string){ "extended" }
        items: (#struct){
          "my-item": (#struct){
            name: (string){ "my-item" }
          }
        }
      }
      broken: (#struct){
        name: (string){ "base" }
        type: (string){ "extended" }
        items: (#struct){
          "my-item": (#struct){
            name: (string){ "my-item" }
          }
        }
      }
      works: (#struct){
        name: (string){ "base" }
        type: (string){ "extended" }
        items: (#struct){
          "my-item": (#struct){
            name: (string){ "my-item" }
          }
        }
      }
    }
  }
  patterns: (_|_){
    // [eval]
    shallow: (_|_){
      // [eval]
      #a: (#struct){
      }
      #b: (#struct){
      }
      #c: (#struct){
      }
      #d: (#struct){
      }
      single: (_|_){
        // [eval]
        X: (#struct){
        }
        err: (_|_){
          // [eval]
          j: (_|_){
            // [eval] patterns.shallow.single.err.j: field not allowed:
            //     ./embed.cue:30:6
            //     ./embed.cue:36:6
            //     ./embed.cue:37:8
            //     ./embed.cue:38:8
          }
        }
        ok: (#struct){
          k: (int){ 3 }
        }
      }
      and: (_|_){
        // [eval]
        p1: (_|_){
          // [eval]
          X: (#struct){
          }
          err: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.and.p1.err.j: field not allowed:
              //     ./embed.cue:30:6
              //     ./embed.cue:31:6
              //     ./embed.cue:45:6
              //     ./embed.cue:45:11
              //     ./embed.cue:47:8
              //     ./embed.cue:48:8
            }
          }
          ok: (#struct){
            k: (int){ 3 }
          }
        }
        p2: (_|_){
          // [eval]
          X: (#struct){
          }
          err: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.and.p2.err.j: field not allowed:
              //     ./embed.cue:30:6
              //     ./embed.cue:31:6
              //     ./embed.cue:55:6
              //     ./embed.cue:55:11
              //     ./embed.cue:56:8
              //     ./embed.cue:57:8
            }
          }
          ok: (#struct){
            k: (int){ 3 }
          }
        }
      }
      andEmbed: (_|_){
        // [eval]
        p1: (_|_){
          // [eval]
          X: (#struct){
          }
          err: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.andEmbed.p1.err.j: field not allowed:
              //     ./embed.cue:30:6
              //     ./embed.cue:31:6
              //     ./embed.cue:64:6
              //     ./embed.cue:64:8
              //     ./embed.cue:64:13
              //     ./embed.cue:66:8
              //     ./embed.cue:67:8
            }
          }
          ok: (#struct){
            k: (int){ 3 }
          }
        }
        p2: (_|_){
          // [eval]
          X: (#struct){
          }
          err: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.andEmbed.p2.err.j: field not allowed:
              //     ./embed.cue:30:6
              //     ./embed.cue:31:6
              //     ./embed.cue:74:6
              //     ./embed.cue:74:8
              //     ./embed.cue:74:13
              //     ./embed.cue:75:8
              //     ./embed.cue:76:8
            }
          }
          ok: (#struct){
            k: (int){ 3 }
          }
        }
      }
      orEmbed: (struct){
        p1: (struct){
          X: (#struct){
          }
          ok1: (#struct){
            j: (int){ 3 }
          }
          ok2: (#struct){
            k: (int){ 3 }
          }
        }
        p2: (struct){
          X: (#struct){
          }
          ok1: (#struct){
            j: (int){ 3 }
          }
          ok2: (#struct){
            k: (int){ 3 }
          }
        }
      }
      andOrEmbed: (_|_){
        // [eval]
        t1: (_|_){
          // [eval]
          p1: (_|_){
            // [eval]
            X: (#struct){
            }
            err1: (_|_){
              // [eval]
              j: (_|_){
                // [eval] patterns.shallow.andOrEmbed.t1.p1.err1.j: field not allowed:
                //     ./embed.cue:30:6
                //     ./embed.cue:31:6
                //     ./embed.cue:32:6
                //     ./embed.cue:33:6
                //     ./embed.cue:103:6
                //     ./embed.cue:104:4
                //     ./embed.cue:104:9
                //     ./embed.cue:105:4
                //     ./embed.cue:105:9
                //     ./embed.cue:107:9
                //     ./embed.cue:108:9
              }
            }
            ok1: (#struct){
              k: (int){ 3 }
            }
          }
          p2: (_|_){
            // [eval]
            X: (#struct){
            }
            err1: (_|_){
              // [eval]
              j: (_|_){
                // [eval] patterns.shallow.andOrEmbed.t1.p2.err1.j: field not allowed:
                //     ./embed.cue:30:6
                //     ./embed.cue:31:6
                //     ./embed.cue:32:6
                //     ./embed.cue:33:6
                //     ./embed.cue:116:6
                //     ./embed.cue:117:4
                //     ./embed.cue:117:9
                //     ./embed.cue:118:4
                //     ./embed.cue:118:9
                //     ./embed.cue:120:9
                //     ./embed.cue:121:9
              }
            }
            ok1: (#struct){
              k: (int){ 3 }
            }
          }
        }
        t2: (_|_){
          // [eval]
          X: (#struct){
          }
          err1: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.andOrEmbed.t2.err1.j: field not allowed:
              //     ./embed.cue:30:6
              //     ./embed.cue:31:6
              //     ./embed.cue:32:6
              //     ./embed.cue:33:6
              //     ./embed.cue:129:6
              //     ./embed.cue:130:4
              //     ./embed.cue:130:9
              //     ./embed.cue:131:4
              //     ./embed.cue:131:9
              //     ./embed.cue:134:9
              //     ./embed.cue:135:9
            }
          }
          ok1: (#struct){
            k: (int){ 3 }
          }
          ok2: (#struct){
            p: (int){ 3 }
          }
        }
      }
      indirect: (_|_){
        // [eval]
        a: (struct){
        }
        #a: (#struct){
        }
        p1: (_|_){
          // [eval]
          X: (#struct){
          }
          err1: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.indirect.p1.err1.j: field not allowed:
              //     ./embed.cue:146:6
              //     ./embed.cue:147:7
              //     ./embed.cue:150:7
              //     ./embed.cue:151:10
              //     ./embed.cue:152:10
            }
          }
          err2: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.indirect.p1.err2.j: field not allowed:
              //     ./embed.cue:146:6
              //     ./embed.cue:147:7
              //     ./embed.cue:150:7
              //     ./embed.cue:154:10
              //     ./embed.cue:155:10
            }
          }
          ok: (#struct){
            k: (int){ 3 }
          }
        }
        p2: (_|_){
          // [eval]
          #a: (#struct){
          }
          X: (#struct){
          }
          err1: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.indirect.p2.err1.j: field not allowed:
              //     ./embed.cue:146:6
              //     ./embed.cue:162:8
              //     ./embed.cue:163:7
              //     ./embed.cue:165:10
              //     ./embed.cue:166:10
            }
          }
          err2: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.indirect.p2.err2.j: field not allowed:
              //     ./embed.cue:146:6
              //     ./embed.cue:162:8
              //     ./embed.cue:163:7
              //     ./embed.cue:168:10
              //     ./embed.cue:169:10
            }
          }
          ok: (#struct){
            k: (int){ 3 }
          }
        }
        p3: (_|_){
          // [eval]
          X: (#struct){
          }
          err1: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.indirect.p3.err1.j: field not allowed:
              //     ./embed.cue:146:6
              //     ./embed.cue:147:7
              //     ./embed.cue:176:7
              //     ./embed.cue:178:10
              //     ./embed.cue:179:10
            }
          }
          err2: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.indirect.p3.err2.j: field not allowed:
              //     ./embed.cue:146:6
              //     ./embed.cue:147:7
              //     ./embed.cue:176:7
              //     ./embed.cue:181:10
              //     ./embed.cue:182:10
            }
          }
          ok: (#struct){
            k: (int){ 3 }
          }
        }
        p4: (_|_){
          // [eval]
          #a: (#struct){
          }
          X: (#struct){
          }
          err1: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.indirect.p4.err1.j: field not allowed:
              //     ./embed.cue:146:6
              //     ./embed.cue:189:8
              //     ./embed.cue:190:7
              //     ./embed.cue:193:10
              //     ./embed.cue:194:10
            }
          }
          err2: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.indirect.p4.err2.j: field not allowed:
              //     ./embed.cue:146:6
              //     ./embed.cue:189:8
              //     ./embed.cue:190:7
              //     ./embed.cue:196:10
              //     ./embed.cue:197:10
            }
          }
          ok: (#struct){
            k: (int){ 3 }
          }
        }
      }
    }
    nested: (_|_){
      // [eval]
      #a: (#struct){
        x: (#struct){
          y: (#struct){
          }
        }
      }
      #b: (#struct){
        x: (#struct){
          y: (#struct){
          }
        }
      }
      #c: (#struct){
        x: (#struct){
          y: (#struct){
          }
        }
      }
      #d: (#struct){
        x: (#struct){
          y: (#struct){
          }
        }
      }
      single: (_|_){
        // [eval]
        X: (#struct){
          x: (#struct){
            y: (#struct){
            }
          }
        }
        err: (_|_){
          // [eval]
          x: (_|_){
            // [eval]
            y: (_|_){
              // [eval]
              j: (_|_){
                // [eval] patterns.nested.single.err.x.y.j: field not allowed:
                //     ./embed.cue:206:12
                //     ./embed.cue:212:6
                //     ./embed.cue:213:8
                //     ./embed.cue:214:14
              }
            }
          }
        }
        ok: (#struct){
          x: (#struct){
            y: (#struct){
              k: (int){ 3 }
            }
          }
        }
      }
      and: (_|_){
        // [eval]
        p1: (_|_){
          // [eval]
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          err: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.and.p1.err.x.y.j: field not allowed:
                  //     ./embed.cue:206:12
                  //     ./embed.cue:207:12
                  //     ./embed.cue:221:6
                  //     ./embed.cue:221:11
                  //     ./embed.cue:223:8
                  //     ./embed.cue:224:14
                }
              }
            }
          }
          ok: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
        p2: (_|_){
          // [eval]
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          err: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.and.p2.err.x.y.j: field not allowed:
                  //     ./embed.cue:206:12
                  //     ./embed.cue:207:12
                  //     ./embed.cue:231:6
                  //     ./embed.cue:231:11
                  //     ./embed.cue:232:8
                  //     ./embed.cue:233:14
                }
              }
            }
          }
          ok: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
      }
      andEmbed: (_|_){
        // [eval]
        p1: (_|_){
          // [eval]
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          err: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.andEmbed.p1.err.x.y.j: field not allowed:
                  //     ./embed.cue:206:12
                  //     ./embed.cue:207:12
                  //     ./embed.cue:240:8
                  //     ./embed.cue:240:13
                  //     ./embed.cue:242:8
                  //     ./embed.cue:243:14
                }
              }
            }
          }
          ok: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
        p2: (_|_){
          // [eval]
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          err: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.andEmbed.p2.err.x.y.j: field not allowed:
                  //     ./embed.cue:206:12
                  //     ./embed.cue:207:12
                  //     ./embed.cue:250:8
                  //     ./embed.cue:250:13
                  //     ./embed.cue:251:8
                  //     ./embed.cue:252:14
                }
              }
            }
          }
          ok: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
      }
      orEmbed: (struct){
        p1: (struct){
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          ok1: (#struct){
            x: (#struct){
              y: (#struct){
                j: (int){ 3 }
              }
            }
          }
          ok2: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
        p2: (struct){
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          ok1: (#struct){
            x: (#struct){
              y: (#struct){
                j: (int){ 3 }
              }
            }
          }
          ok2: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
      }
      andOrEmbed: (_|_){
        // [eval]
        t1: (_|_){
          // [eval]
          p1: (_|_){
            // [eval]
            X: (#struct){
              x: (#struct){
                y: (#struct){
                }
              }
            }
            err1: (_|_){
              // [eval]
              x: (_|_){
                // [eval]
                y: (_|_){
                  // [eval]
                  j: (_|_){
                    // [eval] patterns.nested.andOrEmbed.t1.p1.err1.x.y.j: field not allowed:
                    //     ./embed.cue:206:12
                    //     ./embed.cue:207:12
                    //     ./embed.cue:208:12
                    //     ./embed.cue:209:12
                    //     ./embed.cue:280:4
                    //     ./embed.cue:280:9
                    //     ./embed.cue:281:4
                    //     ./embed.cue:281:9
                    //     ./embed.cue:283:9
                    //     ./embed.cue:284:15
                  }
                }
              }
            }
            ok1: (#struct){
              x: (#struct){
                y: (#struct){
                  k: (int){ 3 }
                }
              }
            }
          }
          p2: (_|_){
            // [eval]
            X: (#struct){
              x: (#struct){
                y: (#struct){
                }
              }
            }
            err1: (_|_){
              // [eval]
              x: (_|_){
                // [eval]
                y: (_|_){
                  // [eval]
                  j: (_|_){
                    // [eval] patterns.nested.andOrEmbed.t1.p2.err1.x.y.j: field not allowed:
                    //     ./embed.cue:206:12
                    //     ./embed.cue:207:12
                    //     ./embed.cue:208:12
                    //     ./embed.cue:209:12
                    //     ./embed.cue:293:4
                    //     ./embed.cue:293:9
                    //     ./embed.cue:294:4
                    //     ./embed.cue:294:9
                    //     ./embed.cue:296:9
                    //     ./embed.cue:297:15
                  }
                }
              }
            }
            ok1: (#struct){
              x: (#struct){
                y: (#struct){
                  k: (int){ 3 }
                }
              }
            }
          }
        }
        t2: (_|_){
          // [eval]
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          err1: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.andOrEmbed.t2.err1.x.y.j: field not allowed:
                  //     ./embed.cue:206:12
                  //     ./embed.cue:207:12
                  //     ./embed.cue:208:12
                  //     ./embed.cue:209:12
                  //     ./embed.cue:306:4
                  //     ./embed.cue:306:9
                  //     ./embed.cue:307:4
                  //     ./embed.cue:307:9
                  //     ./embed.cue:310:9
                  //     ./embed.cue:311:15
                }
              }
            }
          }
          ok1: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
          ok2: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                p: (_|_){
                  // [eval] patterns.nested.andOrEmbed.t2.ok2.x.y.p: field not allowed:
                  //     ./embed.cue:206:12
                  //     ./embed.cue:207:12
                  //     ./embed.cue:208:12
                  //     ./embed.cue:209:12
                  //     ./embed.cue:306:4
                  //     ./embed.cue:306:9
                  //     ./embed.cue:307:4
                  //     ./embed.cue:307:9
                  //     ./embed.cue:316:8
                  //     ./embed.cue:317:14
                }
              }
            }
          }
        }
      }
      indirect: (_|_){
        // [eval]
        a: (struct){
          x: (struct){
            y: (struct){
            }
          }
        }
        #a: (#struct){
          x: (#struct){
            y: (#struct){
            }
          }
        }
        p1: (_|_){
          // [eval]
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          err1: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.indirect.p1.err1.x.y.j: field not allowed:
                  //     ./embed.cue:322:12
                  //     ./embed.cue:323:7
                  //     ./embed.cue:326:7
                  //     ./embed.cue:327:10
                  //     ./embed.cue:328:16
                }
              }
            }
          }
          err2: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.indirect.p1.err2.x.y.j: field not allowed:
                  //     ./embed.cue:322:12
                  //     ./embed.cue:323:7
                  //     ./embed.cue:326:7
                  //     ./embed.cue:330:10
                  //     ./embed.cue:331:16
                }
              }
            }
          }
          ok: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
        p2: (_|_){
          // [eval]
          #a: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          err1: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.indirect.p2.err1.x.y.j: field not allowed:
                  //     ./embed.cue:322:12
                  //     ./embed.cue:338:8
                  //     ./embed.cue:339:7
                  //     ./embed.cue:341:10
                  //     ./embed.cue:342:16
                }
              }
            }
          }
          err2: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.indirect.p2.err2.x.y.j: field not allowed:
                  //     ./embed.cue:322:12
                  //     ./embed.cue:338:8
                  //     ./embed.cue:339:7
                  //     ./embed.cue:344:10
                  //     ./embed.cue:345:16
                }
              }
            }
          }
          ok: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
        p3: (_|_){
          // [eval]
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          err1: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.indirect.p3.err1.x.y.j: field not allowed:
                  //     ./embed.cue:322:12
                  //     ./embed.cue:323:7
                  //     ./embed.cue:352:7
                  //     ./embed.cue:354:10
                  //     ./embed.cue:355:16
                }
              }
            }
          }
          err2: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.indirect.p3.err2.x.y.j: field not allowed:
                  //     ./embed.cue:322:12
                  //     ./embed.cue:323:7
                  //     ./embed.cue:352:7
                  //     ./embed.cue:357:10
                  //     ./embed.cue:358:16
                }
              }
            }
          }
          ok: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
        p4: (_|_){
          // [eval]
          #a: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          err1: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.indirect.p4.err1.x.y.j: field not allowed:
                  //     ./embed.cue:322:12
                  //     ./embed.cue:365:8
                  //     ./embed.cue:366:7
                  //     ./embed.cue:369:10
                  //     ./embed.cue:370:16
                }
              }
            }
          }
          err2: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.indirect.p4.err2.x.y.j: field not allowed:
                  //     ./embed.cue:322:12
                  //     ./embed.cue:365:8
                  //     ./embed.cue:366:7
                  //     ./embed.cue:372:10
                  //     ./embed.cue:373:16
                }
              }
            }
          }
          ok: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
      }
    }
  }
  issue2241: (struct){
    #close: (#struct){
    }
    a: (#struct){
      x: (struct){
        q: (int){ 2 }
      }
    }
    b: (#struct){
      x: (struct){
        q: (int){ 2 }
        r: (int){ 4 }
      }
    }
  }
  #E: (#struct){
    c: (int){ int }
  }
  #A: (#struct){
    b: (int){ int }
    q: (#struct){
      c: (int){ int }
      d: (int){ int }
    }
  }
  a: (_|_){
    // [eval]
    b: (int){ 3 }
    q: (_|_){
      // [eval]
      c: (int){ 2 }
      d: (int){ int }
      e: (_|_){
        // [eval] a.q.e: field not allowed:
        //     ./in.cue:1:5
        //     ./in.cue:6:5
        //     ./in.cue:7:3
        //     ./in.cue:11:4
        //     ./in.cue:15:3
      }
    }
  }
  issue852: (_|_){
    // [eval] issue852.a.Foo: field not allowed:
    //     ./in.cue:22:6
    //     ./in.cue:26:5
    //     ./in.cue:28:5
    #A: (#struct){
    }
    a: (_|_){
      // [eval]
      Foo: (_|_){
        // [eval] issue852.a.Foo: field not allowed:
        //     ./in.cue:22:6
        //     ./in.cue:26:5
        //     ./in.cue:28:5
      }
    }
  }
  dynamic: (struct){
    #D: (#struct){
      key: (string){ "foo" }
      foo: (int){ int }
    }
    d: (#struct){
      key: (string){ "foo" }
      foo: (int){ 3 }
    }
  }
  issue3330: (struct){
    let: (struct){
      ok: (struct){
        #struct: (#struct){
          let empty#1 = (#struct){
          }
          field: (#struct){
            n: (int){ 3 }
          }
        }
        out: (#list){
          0: (#struct){
            let empty#1 = (#struct){
            }
            field: (#struct){
              n: (int){ 3 }
            }
          }
        }
      }
    }
    matthew: (struct){
      ok1: (struct){
        #struct: (#struct){
          field: (#struct){
            n: (int){ 3 }
          }
          g: (#struct){
          }
        }
        out: (#struct){
          field: (#struct){
            n: (int){ 3 }
          }
          g: (#struct){
          }
        }
      }
      ok2: (struct){
        #struct: (#struct){
          field: (#struct){
            n: (int){ 3 }
          }
          g: (#struct){
          }
        }
        out: (#struct){
          field: (#struct){
            n: (int){ 3 }
          }
          g: (#struct){
          }
        }
        out2: (#struct){
          field: (#struct){
            n: (int){ 3 }
          }
          g: (#struct){
          }
        }
      }
    }
  }
  issue3331: (struct){
    original: (struct){
      ok: (#list){
        #A: (#struct){
          let b#2 = (#struct){
          }
          c: (#struct){
            d: (int){ 1 }
          }
        }
        0: (#struct){
          let b#2 = (#struct){
          }
          c: (#struct){
            d: (int){ 1 }
          }
        }
      }
    }
    variant1: (struct){
      ok: (#list){
        #A: (#struct){
          let b#3 = (#struct){
          }
          c: (#struct){
            d: (int){ 1 }
          }
        }
        0: (#list){
          0: (#struct){
            let b#3 = (#struct){
            }
            c: (#struct){
              d: (int){ 1 }
            }
          }
        }
      }
    }
  }
  indirect: (_|_){
    // [eval]
    embed: (struct){
      err1: (struct){
        #A: (#struct){
          x: (#struct){
            a: (#struct){
              b: (int){ 1 }
              c: (int){ 2 }
            }
          }
          zx: (#struct){
            b: (int){ 1 }
            c: (int){ 2 }
          }
        }
        #x: (#struct){
          a: (#struct){
            b: (int){ 1 }
          }
        }
        #y: (#struct){
          a: (#struct){
            c: (int){ 2 }
          }
        }
        b: (#struct){
          x: (#struct){
            a: (#struct){
              b: (int){ 1 }
              c: (int){ 2 }
            }
          }
          zx: (#struct){
            b: (int){ 1 }
            c: (int){ 2 }
          }
        }
        b1: (struct){
          b: (int){ 1 }
          c: (int){ 2 }
          d: (int){ 1 }
        }
      }
    }
    closed: (_|_){
      // [eval]
      err1: (_|_){
        // [eval]
        X: (struct){
          a: (struct){
            e: (int){ 1 }
          }
          b: (struct){
          }
        }
        Y: (_|_){
          // [eval]
          a: (_|_){
            // [eval]
            e: (_|_){
              // [eval] indirect.closed.err1.Y.a.e: field not allowed:
              //     ./reroot.cue:73:7
              //     ./reroot.cue:74:7
              //     ./reroot.cue:75:7
              //     ./reroot.cue:77:6
              //     ./reroot.cue:79:7
              //     ./reroot.cue:80:7
              //     ./reroot.cue:82:7
            }
          }
          b: (#struct){
          }
          c: (#struct){
          }
        }
        #X: (#struct){
        }
      }
    }
  }
  nested: (_|_){
    // [eval]
    ok1: (struct){
      #A: (#struct){
        b: (#struct){
        }
        #B: (#struct){
          c: (#struct){
            d: (int){ 1 }
          }
        }
      }
      x: (#struct){
        b: (#struct){
        }
        #B: (#struct){
          c: (#struct){
            d: (int){ 1 }
          }
        }
      }
    }
    embed: (struct){
      ok: (struct){
        x: (#struct){
          d: (#struct){
            e: (int){ int }
          }
          b: (#struct){
          }
        }
        #A: (#struct){
          d: (#struct){
            e: (int){ int }
          }
          b: (#struct){
          }
        }
        k: (struct){
          d: (struct){
            e: (int){ int }
          }
          b: (struct){
          }
        }
      }
    }
    err1: (_|_){
      // [eval]
      x: (_|_){
        // [eval]
        b: (_|_){
          // [eval]
          f: (_|_){
            // [eval] nested.err1.x.b.f: field not allowed:
            //     ./reroot.cue:112:5
            //     ./reroot.cue:114:6
            //     ./reroot.cue:122:8
            //     ./reroot.cue:123:6
          }
          g: (_|_){
            // [eval] nested.err1.x.b.g: field not allowed:
            //     ./reroot.cue:112:5
            //     ./reroot.cue:114:6
            //     ./reroot.cue:122:8
            //     ./reroot.cue:123:6
          }
        }
        v: (_|_){
          // [eval]
          c: (_|_){
            // [eval]
            f: (_|_){
              // [eval] nested.err1.x.v.c.f: field not allowed:
              //     ./reroot.cue:112:5
              //     ./reroot.cue:114:6
              //     ./reroot.cue:115:6
              //     ./reroot.cue:117:7
              //     ./reroot.cue:117:11
              //     ./reroot.cue:122:8
              //     ./reroot.cue:123:6
            }
            g: (int){ 1 }
            d: (_|_){
              // [eval] nested.err1.x.v.c.d: field not allowed:
              //     ./reroot.cue:112:5
              //     ./reroot.cue:114:6
              //     ./reroot.cue:115:6
              //     ./reroot.cue:117:7
              //     ./reroot.cue:118:5
              //     ./reroot.cue:122:8
              //     ./reroot.cue:123:6
            }
          }
        }
        #V: (_|_){
          // [eval]
          c: (_|_){
            // [eval]
            f: (_|_){
              // [eval] nested.err1.x.#V.c.f: field not allowed:
              //     ./reroot.cue:112:5
              //     ./reroot.cue:114:6
              //     ./reroot.cue:117:7
              //     ./reroot.cue:117:11
              //     ./reroot.cue:122:8
              //     ./reroot.cue:123:6
            }
            g: (int){ 1 }
            d: (_|_){
              // [eval] nested.err1.x.#V.c.d: field not allowed:
              //     ./reroot.cue:112:5
              //     ./reroot.cue:114:6
              //     ./reroot.cue:117:7
              //     ./reroot.cue:118:5
              //     ./reroot.cue:122:8
              //     ./reroot.cue:123:6
            }
          }
        }
      }
      #A: (#struct){
        b: (#struct){
          f: (int){ 1 }
        }
        v: (#struct){
          c: (#struct){
            f: (int){ 1 }
            d: (int){ 1 }
          }
        }
        #V: (#struct){
          c: (#struct){
            f: (int){ 1 }
            d: (int){ 1 }
          }
        }
      }
      #B: (#struct){
        g: (int){ 1 }
      }
    }
    err2: (_|_){
      // [eval]
      #A: (#struct){
        b: (#struct){
        }
        c: (#struct){
          d: (int){ 1 }
        }
      }
      x: (_|_){
        // [eval]
        b: (_|_){
          // [eval]
          g: (_|_){
            // [eval] nested.err2.x.b.g: field not allowed:
            //     ./reroot.cue:128:6
            //     ./reroot.cue:136:5
            //     ./reroot.cue:137:8
          }
        }
        c: (#struct){
          g: (int){ 1 }
          d: (int){ 1 }
        }
      }
    }
  }
  inline: (struct){
    #x: (#struct){
      y: (#struct){
        z?: (#struct){
          name: (string){ string }
        }
      }
    }
    err1: (struct){
      name: (string){ "a" }
      age1: (int){ 5 }
    }
    err2: (struct){
      name: (string){ "a" }
      age2: (int){ 5 }
    }
  }
  mixInDef: (struct){
    refInside: (struct){
      #x: (#struct){
        b: (#struct){
          c: (#struct){
            d: (#struct){
            }
            e: (#struct){
              f: (#struct){
              }
            }
          }
        }
      }
      a: (#struct){
        b: (#struct){
          c: (#struct){
            d: (#struct){
            }
            e: (#struct){
              f: (#struct){
              }
            }
          }
        }
      }
    }
    refEdge: (struct){
      #x: (#struct){
        c: (#struct){
          d: (#struct){
          }
          e: (#struct){
            f: (#struct){
            }
          }
        }
      }
      a: (#struct){
        c: (#struct){
          d: (#struct){
          }
          e: (#struct){
            f: (#struct){
            }
          }
        }
      }
    }
    refOutside: (struct){
      #x: (#struct){
        c: (#struct){
          d: (#struct){
          }
          e: (#struct){
            f: (#struct){
            }
          }
        }
      }
      a: (#struct){
        c: (#struct){
          d: (#struct){
          }
          e: (#struct){
            f: (#struct){
            }
          }
        }
      }
    }
  }
  issue3601: (struct){
    original: (struct){
      out: (#struct){
        foo: (#struct){
          final: (#struct){
            version: (string){ "v1" }
          }
        }
      }
      #Transform: (#struct){
        output: (#struct){
          foo: (#struct){
            final: (#struct){
              version: (string){ "v1" }
            }
          }
        }
      }
      #Patch: (#struct){
        target: (#struct){
        }
        output: (#struct){
          foo: (#struct){
            final: (#struct){
              version: (string){ "v1" }
            }
          }
        }
      }
    }
    originalNoShare: (struct){
      out: (#struct){
        foo: (#struct){
          final: (#struct){
            version: (string){ "v1" }
          }
        }
      }
      #Transform: (#struct){
        output: (#struct){
          foo: (#struct){
            final: (#struct){
              version: (string){ "v1" }
            }
          }
        }
      }
      #Patch: (#struct){
        target: (#struct){
        }
        output: (#struct){
          foo: (#struct){
            final: (#struct){
              version: (string){ "v1" }
            }
          }
        }
      }
    }
    reduced: (struct){
      #X: (#struct){
        a: (#struct){
          b: (#struct){
            c: (string){ "v1" }
          }
        }
        empty: (#struct){
        }
      }
      original: (struct){
        Y: (struct){
          b: (struct){
            c: (string){ "v1" }
          }
        }
        out: (struct){
          b: (struct){
            c: (string){ "v1" }
          }
        }
      }
      moreInlining: (struct){
        out: (struct){
          b: (struct){
            c: (string){ "v1" }
          }
        }
      }
      noInline: (struct){
        Y: (#struct){
          a: (#struct){
            b: (#struct){
              c: (string){ "v1" }
            }
          }
          empty: (#struct){
          }
        }
        Z: (#struct){
          a: (#struct){
            b: (#struct){
              c: (string){ "v1" }
            }
          }
          empty: (#struct){
          }
        }
        out: (struct){
          b: (struct){
            c: (string){ "v1" }
          }
        }
      }
      moreNesting: (struct){
        #X: (#struct){
          a: (#struct){
            b: (#struct){
              c: (#struct){
                d: (string){ "v1" }
              }
            }
          }
          empty: (#struct){
          }
        }
        Y: (struct){
          c: (struct){
            d: (string){ "v1" }
          }
        }
        Z: (struct){
          c: (struct){
            d: (string){ "v1" }
          }
        }
      }
    }
  }
  issue3332: (struct){
    #def: (#struct){
      field: (list){ list.MinItems(1) }
    }
    use: (#struct){
      field: (#list){
        0: (string){ "value" }
      }
    }
  }
}
-- out/evalalpha --
Errors:
a.q.e: field not allowed:
    ./in.cue:15:3
indirect.closed.err1.Y.a.e: field not allowed:
    ./reroot.cue:75:7
issue1867.one.x.foo: field not allowed:
    ./ellipsis.cue:23:5
issue1867.three.x.foo: field not allowed:
    ./ellipsis.cue:37:5
issue1867.two.x.foo: field not allowed:
    ./ellipsis.cue:30:5
issue2241.b.x.r: field not allowed:
    ./embed.cue:390:8
issue3778.full.z.b: field not allowed:
    ./ellipsis.cue:6:3
issue3924.one.out.foo.disallowed: field not allowed:
    ./ellipsis.cue:46:23
issue852.a.Foo: field not allowed:
    ./in.cue:28:5
nested.err1.x.#V.c.d: field not allowed:
    ./reroot.cue:118:5
nested.err1.x.#V.c.f: field not allowed:
    ./reroot.cue:114:6
nested.err1.x.b.f: field not allowed:
    ./reroot.cue:114:6
nested.err1.x.b.g: field not allowed:
    ./reroot.cue:123:6
nested.err2.x.b.g: field not allowed:
    ./reroot.cue:137:8
patterns.nested.and.p1.err.x.y.j: field not allowed:
    ./embed.cue:207:12
    ./embed.cue:224:14
patterns.nested.and.p2.err.x.y.j: field not allowed:
    ./embed.cue:207:12
    ./embed.cue:233:14
patterns.nested.andEmbed.p1.err.x.y.j: field not allowed:
    ./embed.cue:207:12
    ./embed.cue:243:14
patterns.nested.andEmbed.p2.err.x.y.j: field not allowed:
    ./embed.cue:207:12
    ./embed.cue:252:14
patterns.nested.indirect.p1.err1.x.y.j: field not allowed:
    ./embed.cue:328:16
patterns.nested.indirect.p1.err2.x.y.j: field not allowed:
    ./embed.cue:331:16
patterns.nested.indirect.p2.err1.x.y.j: field not allowed:
    ./embed.cue:342:16
patterns.nested.indirect.p2.err2.x.y.j: field not allowed:
    ./embed.cue:345:16
patterns.nested.indirect.p3.err1.x.y.j: field not allowed:
    ./embed.cue:355:16
patterns.nested.indirect.p3.err2.x.y.j: field not allowed:
    ./embed.cue:358:16
patterns.nested.indirect.p4.err1.x.y.j: field not allowed:
    ./embed.cue:370:16
patterns.nested.indirect.p4.err2.x.y.j: field not allowed:
    ./embed.cue:373:16
patterns.nested.single.err.x.y.j: field not allowed:
    ./embed.cue:214:14
patterns.shallow.and.p1.err.j: field not allowed:
    ./embed.cue:31:6
    ./embed.cue:48:8
patterns.shallow.and.p2.err.j: field not allowed:
    ./embed.cue:31:6
    ./embed.cue:57:8
patterns.shallow.andEmbed.p1.err.j: field not allowed:
    ./embed.cue:31:6
    ./embed.cue:67:8
patterns.shallow.andEmbed.p2.err.j: field not allowed:
    ./embed.cue:31:6
    ./embed.cue:76:8
patterns.shallow.indirect.p1.err1.j: field not allowed:
    ./embed.cue:152:10
patterns.shallow.indirect.p1.err2.j: field not allowed:
    ./embed.cue:155:10
patterns.shallow.indirect.p2.err1.j: field not allowed:
    ./embed.cue:166:10
patterns.shallow.indirect.p2.err2.j: field not allowed:
    ./embed.cue:169:10
patterns.shallow.indirect.p3.err1.j: field not allowed:
    ./embed.cue:179:10
patterns.shallow.indirect.p3.err2.j: field not allowed:
    ./embed.cue:182:10
patterns.shallow.indirect.p4.err1.j: field not allowed:
    ./embed.cue:194:10
patterns.shallow.indirect.p4.err2.j: field not allowed:
    ./embed.cue:197:10
patterns.shallow.single.err.j: field not allowed:
    ./embed.cue:38:8
issue3924.two.out.foo.disallowed: field not allowed:
    ./ellipsis.cue:52:9
    ./ellipsis.cue:59:23

Result:
(_|_){
  // [eval]
  issue3778: (_|_){
    // [eval]
    full: (_|_){
      // [eval]
      #x: (#struct){
        a?: (string){ string }
      }
      #y: (#struct){
        a?: (string){ string }
      }
      z: (_|_){
        // [eval]
        a: (string){ "ok" }
        b: (_|_){
          // [eval] issue3778.full.z.b: field not allowed:
          //     ./ellipsis.cue:6:3
        }
      }
    }
    keepOpen: (struct){
      #x: (#struct){
        a?: (string){ string }
      }
      #y: (#struct){
        a?: (string){ string }
      }
      z: (#struct){
        a: (string){ "ok" }
        b: (string){ "something" }
      }
    }
  }
  issue1867: (_|_){
    // [eval]
    one: (_|_){
      // [eval]
      #T: (#struct){
      }
      x: (_|_){
        // [eval]
        foo: (_|_){
          // [eval] issue1867.one.x.foo: field not allowed:
          //     ./ellipsis.cue:23:5
        }
      }
    }
    two: (_|_){
      // [eval]
      #S: (#struct){
      }
      #T: (#struct){
        s: (#struct){
        }
      }
      x: (_|_){
        // [eval]
        foo: (_|_){
          // [eval] issue1867.two.x.foo: field not allowed:
          //     ./ellipsis.cue:30:5
        }
      }
    }
    three: (_|_){
      // [eval]
      #T: (#struct){
        s: (#struct){
        }
      }
      x: (_|_){
        // [eval]
        foo: (_|_){
          // [eval] issue1867.three.x.foo: field not allowed:
          //     ./ellipsis.cue:37:5
        }
      }
    }
  }
  issue3924: (_|_){
    // [eval]
    one: (_|_){
      // [eval]
      #Schema: (#struct){
      }
      #SchemaInner: (#struct){
        allowed?: (string){ string }
      }
      out: (_|_){
        // [eval]
        foo: (_|_){
          // [eval]
          disallowed: (_|_){
            // [eval] issue3924.one.out.foo.disallowed: field not allowed:
            //     ./ellipsis.cue:46:23
          }
          allowed?: (string){ string }
        }
      }
    }
    two: (_|_){
      // [eval]
      #Schema: (#struct){
        #job: (#struct){
          allowed?: (string){ string }
        }
      }
      out: (_|_){
        // [eval]
        foo: (_|_){
          // [eval] issue3924.two.out.foo.disallowed: field not allowed:
          //     ./ellipsis.cue:52:9
          //     ./ellipsis.cue:59:23
          disallowed: (_|_){
            // [eval] issue3924.two.out.foo.disallowed: field not allowed:
            //     ./ellipsis.cue:52:9
            //     ./ellipsis.cue:59:23
          }
          allowed?: (string){ string }
        }
        #job: (#struct){
          allowed?: (string){ string }
        }
      }
    }
  }
  issue3325: (struct){
    ok: (struct){
      #Items: (#struct){
      }
      #Base: (#struct){
        name: (string){ "base" }
        type: (string){ string }
        items: (#struct){
        }
      }
      #Extended: (#struct){
        type: (string){ "extended" }
        items: (#struct){
          "my-item": (#struct){
            name: (string){ "my-item" }
          }
        }
        name: (string){ "base" }
      }
      broken: (#struct){
        name: (string){ "base" }
        type: (string){ "extended" }
        items: (#struct){
          "my-item": (#struct){
            name: (string){ "my-item" }
          }
        }
      }
      works: (#struct){
        type: (string){ "extended" }
        items: (#struct){
          "my-item": (#struct){
            name: (string){ "my-item" }
          }
        }
        name: (string){ "base" }
      }
    }
  }
  patterns: (_|_){
    // [eval]
    shallow: (_|_){
      // [eval]
      #a: (#struct){
      }
      #b: (#struct){
      }
      #c: (#struct){
      }
      #d: (#struct){
      }
      single: (_|_){
        // [eval]
        X: (#struct){
        }
        err: (_|_){
          // [eval]
          j: (_|_){
            // [eval] patterns.shallow.single.err.j: field not allowed:
            //     ./embed.cue:38:8
          }
        }
        ok: (#struct){
          k: (int){ 3 }
        }
      }
      and: (_|_){
        // [eval]
        p1: (_|_){
          // [eval]
          X: (#struct){
          }
          err: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.and.p1.err.j: field not allowed:
              //     ./embed.cue:31:6
              //     ./embed.cue:48:8
            }
          }
          ok: (#struct){
            k: (int){ 3 }
          }
        }
        p2: (_|_){
          // [eval]
          X: (#struct){
          }
          err: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.and.p2.err.j: field not allowed:
              //     ./embed.cue:31:6
              //     ./embed.cue:57:8
            }
          }
          ok: (#struct){
            k: (int){ 3 }
          }
        }
      }
      andEmbed: (_|_){
        // [eval]
        p1: (_|_){
          // [eval]
          X: (#struct){
          }
          err: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.andEmbed.p1.err.j: field not allowed:
              //     ./embed.cue:31:6
              //     ./embed.cue:67:8
            }
          }
          ok: (#struct){
            k: (int){ 3 }
          }
        }
        p2: (_|_){
          // [eval]
          X: (#struct){
          }
          err: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.andEmbed.p2.err.j: field not allowed:
              //     ./embed.cue:31:6
              //     ./embed.cue:76:8
            }
          }
          ok: (#struct){
            k: (int){ 3 }
          }
        }
      }
      orEmbed: (struct){
        p1: (struct){
          X: (#struct){
          }
          ok1: (#struct){
            j: (int){ 3 }
          }
          ok2: (#struct){
            k: (int){ 3 }
          }
        }
        p2: (struct){
          X: (#struct){
          }
          ok1: (#struct){
            j: (int){ 3 }
          }
          ok2: (#struct){
            k: (int){ 3 }
          }
        }
      }
      andOrEmbed: (struct){
        t1: (struct){
          p1: (struct){
            X: (#struct){
            }
            err1: (#struct){
              j: (int){ 3 }
            }
            ok1: (#struct){
              k: (int){ 3 }
            }
          }
          p2: (struct){
            X: (#struct){
            }
            err1: (#struct){
              j: (int){ 3 }
            }
            ok1: (#struct){
              k: (int){ 3 }
            }
          }
        }
        t2: (struct){
          X: (#struct){
          }
          err1: (#struct){
            j: (int){ 3 }
          }
          ok1: (#struct){
            k: (int){ 3 }
          }
          ok2: (#struct){
            p: (int){ 3 }
          }
        }
      }
      indirect: (_|_){
        // [eval]
        a: (struct){
        }
        #a: (#struct){
        }
        p1: (_|_){
          // [eval]
          X: (#struct){
          }
          err1: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.indirect.p1.err1.j: field not allowed:
              //     ./embed.cue:152:10
            }
          }
          err2: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.indirect.p1.err2.j: field not allowed:
              //     ./embed.cue:155:10
            }
          }
          ok: (#struct){
            k: (int){ 3 }
          }
        }
        p2: (_|_){
          // [eval]
          #a: (#struct){
          }
          X: (#struct){
          }
          err1: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.indirect.p2.err1.j: field not allowed:
              //     ./embed.cue:166:10
            }
          }
          err2: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.indirect.p2.err2.j: field not allowed:
              //     ./embed.cue:169:10
            }
          }
          ok: (#struct){
            k: (int){ 3 }
          }
        }
        p3: (_|_){
          // [eval]
          X: (#struct){
          }
          err1: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.indirect.p3.err1.j: field not allowed:
              //     ./embed.cue:179:10
            }
          }
          err2: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.indirect.p3.err2.j: field not allowed:
              //     ./embed.cue:182:10
            }
          }
          ok: (#struct){
            k: (int){ 3 }
          }
        }
        p4: (_|_){
          // [eval]
          #a: (#struct){
          }
          X: (#struct){
          }
          err1: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.indirect.p4.err1.j: field not allowed:
              //     ./embed.cue:194:10
            }
          }
          err2: (_|_){
            // [eval]
            j: (_|_){
              // [eval] patterns.shallow.indirect.p4.err2.j: field not allowed:
              //     ./embed.cue:197:10
            }
          }
          ok: (#struct){
            k: (int){ 3 }
          }
        }
      }
    }
    nested: (_|_){
      // [eval]
      #a: (#struct){
        x: (#struct){
          y: (#struct){
          }
        }
      }
      #b: (#struct){
        x: (#struct){
          y: (#struct){
          }
        }
      }
      #c: (#struct){
        x: (#struct){
          y: (#struct){
          }
        }
      }
      #d: (#struct){
        x: (#struct){
          y: (#struct){
          }
        }
      }
      single: (_|_){
        // [eval]
        X: ~(patterns.nested.#a)
        err: (_|_){
          // [eval]
          x: (_|_){
            // [eval]
            y: (_|_){
              // [eval]
              j: (_|_){
                // [eval] patterns.nested.single.err.x.y.j: field not allowed:
                //     ./embed.cue:214:14
              }
            }
          }
        }
        ok: (#struct){
          x: (#struct){
            y: (#struct){
              k: (int){ 3 }
            }
          }
        }
      }
      and: (_|_){
        // [eval]
        p1: (_|_){
          // [eval]
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          err: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.and.p1.err.x.y.j: field not allowed:
                  //     ./embed.cue:207:12
                  //     ./embed.cue:224:14
                }
              }
            }
          }
          ok: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
        p2: (_|_){
          // [eval]
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          err: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.and.p2.err.x.y.j: field not allowed:
                  //     ./embed.cue:207:12
                  //     ./embed.cue:233:14
                }
              }
            }
          }
          ok: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
      }
      andEmbed: (_|_){
        // [eval]
        p1: (_|_){
          // [eval]
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          err: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.andEmbed.p1.err.x.y.j: field not allowed:
                  //     ./embed.cue:207:12
                  //     ./embed.cue:243:14
                }
              }
            }
          }
          ok: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
        p2: (_|_){
          // [eval]
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          err: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.andEmbed.p2.err.x.y.j: field not allowed:
                  //     ./embed.cue:207:12
                  //     ./embed.cue:252:14
                }
              }
            }
          }
          ok: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
      }
      orEmbed: (struct){
        p1: (struct){
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          ok1: (#struct){
            x: (#struct){
              y: (#struct){
                j: (int){ 3 }
              }
            }
          }
          ok2: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
        p2: (struct){
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          ok1: (#struct){
            x: (#struct){
              y: (#struct){
                j: (int){ 3 }
              }
            }
          }
          ok2: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
      }
      andOrEmbed: (struct){
        t1: (struct){
          p1: (struct){
            X: (#struct){
              x: (#struct){
                y: (#struct){
                }
              }
            }
            err1: (#struct){
              x: (#struct){
                y: (#struct){
                  j: (int){ 3 }
                }
              }
            }
            ok1: (#struct){
              x: (#struct){
                y: (#struct){
                  k: (int){ 3 }
                }
              }
            }
          }
          p2: (struct){
            X: (#struct){
              x: (#struct){
                y: (#struct){
                }
              }
            }
            err1: (#struct){
              x: (#struct){
                y: (#struct){
                  j: (int){ 3 }
                }
              }
            }
            ok1: (#struct){
              x: (#struct){
                y: (#struct){
                  k: (int){ 3 }
                }
              }
            }
          }
        }
        t2: (struct){
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          err1: (#struct){
            x: (#struct){
              y: (#struct){
                j: (int){ 3 }
              }
            }
          }
          ok1: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
          ok2: (#struct){
            x: (#struct){
              y: (#struct){
                p: (int){ 3 }
              }
            }
          }
        }
      }
      indirect: (_|_){
        // [eval]
        a: (struct){
          x: (struct){
            y: (struct){
            }
          }
        }
        #a: (#struct){
          x: (#struct){
            y: (#struct){
            }
          }
        }
        p1: (_|_){
          // [eval]
          X: ~(patterns.nested.indirect.#a)
          err1: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.indirect.p1.err1.x.y.j: field not allowed:
                  //     ./embed.cue:328:16
                }
              }
            }
          }
          err2: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.indirect.p1.err2.x.y.j: field not allowed:
                  //     ./embed.cue:331:16
                }
              }
            }
          }
          ok: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
        p2: (_|_){
          // [eval]
          #a: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          X: ~(patterns.nested.indirect.p2.#a)
          err1: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.indirect.p2.err1.x.y.j: field not allowed:
                  //     ./embed.cue:342:16
                }
              }
            }
          }
          err2: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.indirect.p2.err2.x.y.j: field not allowed:
                  //     ./embed.cue:345:16
                }
              }
            }
          }
          ok: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
        p3: (_|_){
          // [eval]
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          err1: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.indirect.p3.err1.x.y.j: field not allowed:
                  //     ./embed.cue:355:16
                }
              }
            }
          }
          err2: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.indirect.p3.err2.x.y.j: field not allowed:
                  //     ./embed.cue:358:16
                }
              }
            }
          }
          ok: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
        p4: (_|_){
          // [eval]
          #a: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          X: (#struct){
            x: (#struct){
              y: (#struct){
              }
            }
          }
          err1: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.indirect.p4.err1.x.y.j: field not allowed:
                  //     ./embed.cue:370:16
                }
              }
            }
          }
          err2: (_|_){
            // [eval]
            x: (_|_){
              // [eval]
              y: (_|_){
                // [eval]
                j: (_|_){
                  // [eval] patterns.nested.indirect.p4.err2.x.y.j: field not allowed:
                  //     ./embed.cue:373:16
                }
              }
            }
          }
          ok: (#struct){
            x: (#struct){
              y: (#struct){
                k: (int){ 3 }
              }
            }
          }
        }
      }
    }
  }
  issue2241: (_|_){
    // [eval]
    #close: (#struct){
    }
    a: (#struct){
      x: (struct){
        q: (int){ 2 }
      }
    }
    b: (_|_){
      // [eval]
      x: (_|_){
        // [eval]
        r: (_|_){
          // [eval] issue2241.b.x.r: field not allowed:
          //     ./embed.cue:390:8
        }
        q: (int){ 2 }
      }
    }
  }
  #E: (#struct){
    c: (int){ int }
  }
  #A: (#struct){
    b: (int){ int }
    q: (#struct){
      d: (int){ int }
      c: (int){ int }
    }
  }
  a: (_|_){
    // [eval]
    b: (int){ 3 }
    q: (_|_){
      // [eval]
      c: (int){ 2 }
      e: (_|_){
        // [eval] a.q.e: field not allowed:
        //     ./in.cue:15:3
      }
      d: (int){ int }
    }
  }
  issue852: (_|_){
    // [eval] issue852.a.Foo: field not allowed:
    //     ./in.cue:28:5
    #A: (#struct){
    }
    a: (_|_){
      // [eval]
      Foo: (_|_){
        // [eval] issue852.a.Foo: field not allowed:
        //     ./in.cue:28:5
      }
    }
  }
  dynamic: (struct){
    #D: (#struct){
      key: (string){ "foo" }
      foo: (int){ int }
    }
    d: (#struct){
      foo: (int){ 3 }
      key: (string){ "foo" }
    }
  }
  issue3330: (struct){
    let: (struct){
      ok: (struct){
        #struct: (#struct){
          let empty#1 = (#struct){
          }
          field: (#struct){
            n: (int){ 3 }
          }
        }
        out: (#list){
          0: ~(issue3330.let.ok.#struct)
        }
      }
    }
    matthew: (struct){
      ok1: (struct){
        #struct: (#struct){
          field: (#struct){
            n: (int){ 3 }
          }
          g: (#struct){
          }
        }
        out: (#struct){
          field: (#struct){
            n: (int){ 3 }
          }
          g: (#struct){
          }
        }
      }
      ok2: (struct){
        #struct: (#struct){
          field: (#struct){
            n: (int){ 3 }
          }
          g: (#struct){
          }
        }
        out: ~(issue3330.matthew.ok2.#struct)
        out2: (#struct){
          field: (#struct){
            n: (int){ 3 }
          }
          g: (#struct){
          }
        }
      }
    }
  }
  issue3331: (struct){
    original: (struct){
      ok: (#list){
        #A: (#struct){
          let b#2 = (#struct){
          }
          c: (#struct){
            d: (int){ 1 }
          }
        }
        0: ~(issue3331.original.ok.#A)
      }
    }
    variant1: (struct){
      ok: (#list){
        #A: (#struct){
          let b#3 = (#struct){
          }
          c: (#struct){
            d: (int){ 1 }
          }
        }
        0: (#list){
          0: ~(issue3331.variant1.ok.#A)
        }
      }
    }
  }
  indirect: (_|_){
    // [eval]
    embed: (struct){
      err1: (struct){
        #A: (#struct){
          x: (#struct){
            a: (#struct){
              b: (int){ 1 }
              c: (int){ 2 }
            }
          }
          zx: ~(indirect.embed.err1.#A.x.a)
        }
        #x: (#struct){
          a: (#struct){
            b: (int){ 1 }
          }
        }
        #y: (#struct){
          a: (#struct){
            c: (int){ 2 }
          }
        }
        b: ~(indirect.embed.err1.#A)
        b1: (#struct){
          d: (int){ 1 }
          b: (int){ 1 }
          c: (int){ 2 }
        }
      }
    }
    closed: (_|_){
      // [eval]
      err1: (_|_){
        // [eval]
        X: (struct){
          a: (struct){
            e: (int){ 1 }
          }
          b: (struct){
          }
        }
        Y: (_|_){
          // [eval]
          b: (#struct){
          }
          c: (#struct){
          }
          a: (_|_){
            // [eval]
            e: (_|_){
              // [eval] indirect.closed.err1.Y.a.e: field not allowed:
              //     ./reroot.cue:75:7
            }
          }
        }
        #X: (#struct){
        }
      }
    }
  }
  nested: (_|_){
    // [eval]
    ok1: (struct){
      #A: (#struct){
        b: (#struct){
        }
        #B: (#struct){
          c: (#struct){
            d: (int){ 1 }
          }
        }
      }
      x: ~(nested.ok1.#A)
    }
    embed: (struct){
      ok: (struct){
        x: ~(nested.embed.ok.#A)
        #A: (#struct){
          d: (#struct){
            e: (int){ int }
          }
          b: (#struct){
          }
        }
        k: (struct){
          d: (struct){
            e: (int){ int }
          }
          b: (struct){
          }
        }
      }
    }
    err1: (_|_){
      // [eval]
      x: (_|_){
        // [eval]
        b: (_|_){
          // [eval]
          f: (_|_){
            // [eval] nested.err1.x.b.f: field not allowed:
            //     ./reroot.cue:114:6
          }
          g: (_|_){
            // [eval] nested.err1.x.b.g: field not allowed:
            //     ./reroot.cue:123:6
          }
        }
        v: ~(nested.err1.x.#V)
        #V: (_|_){
          // [eval]
          c: (_|_){
            // [eval]
            d: (_|_){
              // [eval] nested.err1.x.#V.c.d: field not allowed:
              //     ./reroot.cue:118:5
            }
            f: (_|_){
              // [eval] nested.err1.x.#V.c.f: field not allowed:
              //     ./reroot.cue:114:6
            }
            g: (int){ 1 }
          }
        }
      }
      #A: (#struct){
        b: (#struct){
          f: (int){ 1 }
        }
        v: ~(nested.err1.#A.#V)
        #V: (#struct){
          c: (#struct){
            d: (int){ 1 }
            f: (int){ 1 }
          }
        }
      }
      #B: (#struct){
        g: (int){ 1 }
      }
    }
    err2: (_|_){
      // [eval]
      #A: (#struct){
        b: (#struct){
        }
        c: (#struct){
          d: (int){ 1 }
        }
      }
      x: (_|_){
        // [eval]
        b: (_|_){
          // [eval]
          g: (_|_){
            // [eval] nested.err2.x.b.g: field not allowed:
            //     ./reroot.cue:137:8
          }
        }
        c: (#struct){
          d: (int){ 1 }
          g: (int){ 1 }
        }
      }
    }
  }
  inline: (struct){
    #x: (#struct){
      y: (#struct){
        z?: (#struct){
          name: (string){ string }
        }
      }
    }
    err1: (#struct){
      name: (string){ "a" }
      age1: (int){ 5 }
    }
    err2: (#struct){
      name: (string){ "a" }
      age2: (int){ 5 }
    }
  }
  mixInDef: (struct){
    refInside: (struct){
      #x: (#struct){
        b: (#struct){
          c: (#struct){
            d: (#struct){
            }
            e: (#struct){
              f: (#struct){
              }
            }
          }
        }
      }
      a: (#struct){
        b: (#struct){
          c: (#struct){
            d: (#struct){
            }
            e: (#struct){
              f: (#struct){
              }
            }
          }
        }
      }
    }
    refEdge: (struct){
      #x: (#struct){
        c: (#struct){
          d: (#struct){
          }
          e: (#struct){
            f: (#struct){
            }
          }
        }
      }
      a: (#struct){
        c: (#struct){
          d: (#struct){
          }
          e: (#struct){
            f: (#struct){
            }
          }
        }
      }
    }
    refOutside: (struct){
      #x: (#struct){
        c: (#struct){
          d: (#struct){
          }
          e: (#struct){
            f: (#struct){
            }
          }
        }
      }
      a: (#struct){
        c: (#struct){
          d: (#struct){
          }
          e: (#struct){
            f: (#struct){
            }
          }
        }
      }
    }
  }
  issue3601: (struct){
    original: (struct){
      out: (#struct){
        foo: (#struct){
          final: (#struct){
            version: (string){ "v1" }
          }
        }
      }
      #Transform: (#struct){
        output: (#struct){
          foo: (#struct){
            final: (#struct){
              version: (string){ "v1" }
            }
          }
        }
      }
      #Patch: (#struct){
        target: (#struct){
        }
        output: (#struct){
          foo: (#struct){
            final: (#struct){
              version: (string){ "v1" }
            }
          }
        }
      }
    }
    originalNoShare: (struct){
      out: (#struct){
        foo: (#struct){
          final: (#struct){
            version: (string){ "v1" }
          }
        }
      }
      #Transform: (#struct){
        output: (#struct){
          foo: (#struct){
            final: (#struct){
              version: (string){ "v1" }
            }
          }
        }
      }
      #Patch: (#struct){
        target: (#struct){
        }
        output: (#struct){
          foo: (#struct){
            final: (#struct){
              version: (string){ "v1" }
            }
          }
        }
      }
    }
    reduced: (struct){
      #X: (#struct){
        a: (#struct){
          b: (#struct){
            c: (string){ "v1" }
          }
        }
        empty: (#struct){
        }
      }
      original: (struct){
        Y: (#struct){
          b: (#struct){
            c: (string){ "v1" }
          }
        }
        out: (#struct){
          b: (#struct){
            c: (string){ "v1" }
          }
        }
      }
      moreInlining: (struct){
        out: (#struct){
          b: (#struct){
            c: (string){ "v1" }
          }
        }
      }
      noInline: (struct){
        Y: (#struct){
          a: (#struct){
            b: (#struct){
              c: (string){ "v1" }
            }
          }
          empty: (#struct){
          }
        }
        Z: (#struct){
          a: (#struct){
            b: (#struct){
              c: (string){ "v1" }
            }
          }
          empty: (#struct){
          }
        }
        out: (#struct){
          b: (#struct){
            c: (string){ "v1" }
          }
        }
      }
      moreNesting: (struct){
        #X: (#struct){
          a: (#struct){
            b: (#struct){
              c: (#struct){
                d: (string){ "v1" }
              }
            }
          }
          empty: (#struct){
          }
        }
        Y: (#struct){
          c: (#struct){
            d: (string){ "v1" }
          }
        }
        Z: (#struct){
          c: (#struct){
            d: (string){ "v1" }
          }
        }
      }
    }
  }
  issue3332: (struct){
    #def: (#struct){
      field: (list){ list.MinItems(1) }
    }
    use: (#struct){
      field: (#list){
        0: (string){ "value" }
      }
    }
  }
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -1,349 +1,94 @@
 Errors:
 a.q.e: field not allowed:
-    ./in.cue:1:5
-    ./in.cue:6:5
-    ./in.cue:7:3
-    ./in.cue:11:4
     ./in.cue:15:3
 indirect.closed.err1.Y.a.e: field not allowed:
-    ./reroot.cue:73:7
-    ./reroot.cue:74:7
     ./reroot.cue:75:7
-    ./reroot.cue:77:6
-    ./reroot.cue:79:7
-    ./reroot.cue:80:7
-    ./reroot.cue:82:7
 issue1867.one.x.foo: field not allowed:
-    ./ellipsis.cue:20:12
-    ./ellipsis.cue:21:7
-    ./ellipsis.cue:22:5
     ./ellipsis.cue:23:5
 issue1867.three.x.foo: field not allowed:
-    ./ellipsis.cue:34:15
-    ./ellipsis.cue:35:10
-    ./ellipsis.cue:36:5
     ./ellipsis.cue:37:5
 issue1867.two.x.foo: field not allowed:
-    ./ellipsis.cue:26:6
-    ./ellipsis.cue:27:9
-    ./ellipsis.cue:28:10
-    ./ellipsis.cue:29:5
     ./ellipsis.cue:30:5
+issue2241.b.x.r: field not allowed:
+    ./embed.cue:390:8
 issue3778.full.z.b: field not allowed:
-    ./ellipsis.cue:2:6
-    ./ellipsis.cue:3:6
-    ./ellipsis.cue:3:13
-    ./ellipsis.cue:4:5
     ./ellipsis.cue:6:3
 issue3924.one.out.foo.disallowed: field not allowed:
-    ./ellipsis.cue:42:3
-    ./ellipsis.cue:42:14
-    ./ellipsis.cue:44:16
-    ./ellipsis.cue:46:7
     ./ellipsis.cue:46:23
 issue852.a.Foo: field not allowed:
-    ./in.cue:22:6
-    ./in.cue:26:5
     ./in.cue:28:5
 nested.err1.x.#V.c.d: field not allowed:
-    ./reroot.cue:112:5
-    ./reroot.cue:114:6
-    ./reroot.cue:117:7
-    ./reroot.cue:118:5
-    ./reroot.cue:122:8
-    ./reroot.cue:123:6
+    ./reroot.cue:118:5
 nested.err1.x.#V.c.f: field not allowed:
-    ./reroot.cue:112:5
-    ./reroot.cue:114:6
-    ./reroot.cue:117:7
-    ./reroot.cue:117:11
-    ./reroot.cue:122:8
-    ./reroot.cue:123:6
+    ./reroot.cue:114:6
 nested.err1.x.b.f: field not allowed:
-    ./reroot.cue:112:5
-    ./reroot.cue:114:6
-    ./reroot.cue:122:8
-    ./reroot.cue:123:6
+    ./reroot.cue:114:6
 nested.err1.x.b.g: field not allowed:
-    ./reroot.cue:112:5
-    ./reroot.cue:114:6
-    ./reroot.cue:122:8
-    ./reroot.cue:123:6
-nested.err1.x.v.c.d: field not allowed:
-    ./reroot.cue:112:5
-    ./reroot.cue:114:6
-    ./reroot.cue:115:6
-    ./reroot.cue:117:7
-    ./reroot.cue:118:5
-    ./reroot.cue:122:8
-    ./reroot.cue:123:6
-nested.err1.x.v.c.f: field not allowed:
-    ./reroot.cue:112:5
-    ./reroot.cue:114:6
-    ./reroot.cue:115:6
-    ./reroot.cue:117:7
-    ./reroot.cue:117:11
-    ./reroot.cue:122:8
     ./reroot.cue:123:6
 nested.err2.x.b.g: field not allowed:
-    ./reroot.cue:128:6
-    ./reroot.cue:136:5
     ./reroot.cue:137:8
 patterns.nested.and.p1.err.x.y.j: field not allowed:
-    ./embed.cue:206:12
-    ./embed.cue:207:12
-    ./embed.cue:221:6
-    ./embed.cue:221:11
-    ./embed.cue:223:8
+    ./embed.cue:207:12
     ./embed.cue:224:14
 patterns.nested.and.p2.err.x.y.j: field not allowed:
-    ./embed.cue:206:12
-    ./embed.cue:207:12
-    ./embed.cue:231:6
-    ./embed.cue:231:11
-    ./embed.cue:232:8
+    ./embed.cue:207:12
     ./embed.cue:233:14
 patterns.nested.andEmbed.p1.err.x.y.j: field not allowed:
-    ./embed.cue:206:12
-    ./embed.cue:207:12
-    ./embed.cue:240:8
-    ./embed.cue:240:13
-    ./embed.cue:242:8
+    ./embed.cue:207:12
     ./embed.cue:243:14
 patterns.nested.andEmbed.p2.err.x.y.j: field not allowed:
-    ./embed.cue:206:12
-    ./embed.cue:207:12
-    ./embed.cue:250:8
-    ./embed.cue:250:13
-    ./embed.cue:251:8
+    ./embed.cue:207:12
     ./embed.cue:252:14
-patterns.nested.andOrEmbed.t1.p1.err1.x.y.j: field not allowed:
-    ./embed.cue:206:12
-    ./embed.cue:207:12
-    ./embed.cue:208:12
-    ./embed.cue:209:12
-    ./embed.cue:280:4
-    ./embed.cue:280:9
-    ./embed.cue:281:4
-    ./embed.cue:281:9
-    ./embed.cue:283:9
-    ./embed.cue:284:15
-patterns.nested.andOrEmbed.t1.p2.err1.x.y.j: field not allowed:
-    ./embed.cue:206:12
-    ./embed.cue:207:12
-    ./embed.cue:208:12
-    ./embed.cue:209:12
-    ./embed.cue:293:4
-    ./embed.cue:293:9
-    ./embed.cue:294:4
-    ./embed.cue:294:9
-    ./embed.cue:296:9
-    ./embed.cue:297:15
-patterns.nested.andOrEmbed.t2.err1.x.y.j: field not allowed:
-    ./embed.cue:206:12
-    ./embed.cue:207:12
-    ./embed.cue:208:12
-    ./embed.cue:209:12
-    ./embed.cue:306:4
-    ./embed.cue:306:9
-    ./embed.cue:307:4
-    ./embed.cue:307:9
-    ./embed.cue:310:9
-    ./embed.cue:311:15
-patterns.nested.andOrEmbed.t2.ok2.x.y.p: field not allowed:
-    ./embed.cue:206:12
-    ./embed.cue:207:12
-    ./embed.cue:208:12
-    ./embed.cue:209:12
-    ./embed.cue:306:4
-    ./embed.cue:306:9
-    ./embed.cue:307:4
-    ./embed.cue:307:9
-    ./embed.cue:316:8
-    ./embed.cue:317:14
 patterns.nested.indirect.p1.err1.x.y.j: field not allowed:
-    ./embed.cue:322:12
-    ./embed.cue:323:7
-    ./embed.cue:326:7
-    ./embed.cue:327:10
     ./embed.cue:328:16
 patterns.nested.indirect.p1.err2.x.y.j: field not allowed:
-    ./embed.cue:322:12
-    ./embed.cue:323:7
-    ./embed.cue:326:7
-    ./embed.cue:330:10
     ./embed.cue:331:16
 patterns.nested.indirect.p2.err1.x.y.j: field not allowed:
-    ./embed.cue:322:12
-    ./embed.cue:338:8
-    ./embed.cue:339:7
-    ./embed.cue:341:10
     ./embed.cue:342:16
 patterns.nested.indirect.p2.err2.x.y.j: field not allowed:
-    ./embed.cue:322:12
-    ./embed.cue:338:8
-    ./embed.cue:339:7
-    ./embed.cue:344:10
     ./embed.cue:345:16
 patterns.nested.indirect.p3.err1.x.y.j: field not allowed:
-    ./embed.cue:322:12
-    ./embed.cue:323:7
-    ./embed.cue:352:7
-    ./embed.cue:354:10
     ./embed.cue:355:16
 patterns.nested.indirect.p3.err2.x.y.j: field not allowed:
-    ./embed.cue:322:12
-    ./embed.cue:323:7
-    ./embed.cue:352:7
-    ./embed.cue:357:10
     ./embed.cue:358:16
 patterns.nested.indirect.p4.err1.x.y.j: field not allowed:
-    ./embed.cue:322:12
-    ./embed.cue:365:8
-    ./embed.cue:366:7
-    ./embed.cue:369:10
     ./embed.cue:370:16
 patterns.nested.indirect.p4.err2.x.y.j: field not allowed:
-    ./embed.cue:322:12
-    ./embed.cue:365:8
-    ./embed.cue:366:7
-    ./embed.cue:372:10
     ./embed.cue:373:16
 patterns.nested.single.err.x.y.j: field not allowed:
-    ./embed.cue:206:12
-    ./embed.cue:212:6
-    ./embed.cue:213:8
     ./embed.cue:214:14
 patterns.shallow.and.p1.err.j: field not allowed:
-    ./embed.cue:30:6
-    ./embed.cue:31:6
-    ./embed.cue:45:6
-    ./embed.cue:45:11
-    ./embed.cue:47:8
+    ./embed.cue:31:6
     ./embed.cue:48:8
 patterns.shallow.and.p2.err.j: field not allowed:
-    ./embed.cue:30:6
-    ./embed.cue:31:6
-    ./embed.cue:55:6
-    ./embed.cue:55:11
-    ./embed.cue:56:8
+    ./embed.cue:31:6
     ./embed.cue:57:8
 patterns.shallow.andEmbed.p1.err.j: field not allowed:
-    ./embed.cue:30:6
-    ./embed.cue:31:6
-    ./embed.cue:64:6
-    ./embed.cue:64:8
-    ./embed.cue:64:13
-    ./embed.cue:66:8
+    ./embed.cue:31:6
     ./embed.cue:67:8
 patterns.shallow.andEmbed.p2.err.j: field not allowed:
-    ./embed.cue:30:6
-    ./embed.cue:31:6
-    ./embed.cue:74:6
-    ./embed.cue:74:8
-    ./embed.cue:74:13
-    ./embed.cue:75:8
+    ./embed.cue:31:6
     ./embed.cue:76:8
-patterns.shallow.andOrEmbed.t1.p1.err1.j: field not allowed:
-    ./embed.cue:30:6
-    ./embed.cue:31:6
-    ./embed.cue:32:6
-    ./embed.cue:33:6
-    ./embed.cue:103:6
-    ./embed.cue:104:4
-    ./embed.cue:104:9
-    ./embed.cue:105:4
-    ./embed.cue:105:9
-    ./embed.cue:107:9
-    ./embed.cue:108:9
-patterns.shallow.andOrEmbed.t1.p2.err1.j: field not allowed:
-    ./embed.cue:30:6
-    ./embed.cue:31:6
-    ./embed.cue:32:6
-    ./embed.cue:33:6
-    ./embed.cue:116:6
-    ./embed.cue:117:4
-    ./embed.cue:117:9
-    ./embed.cue:118:4
-    ./embed.cue:118:9
-    ./embed.cue:120:9
-    ./embed.cue:121:9
-patterns.shallow.andOrEmbed.t2.err1.j: field not allowed:
-    ./embed.cue:30:6
-    ./embed.cue:31:6
-    ./embed.cue:32:6
-    ./embed.cue:33:6
-    ./embed.cue:129:6
-    ./embed.cue:130:4
-    ./embed.cue:130:9
-    ./embed.cue:131:4
-    ./embed.cue:131:9
-    ./embed.cue:134:9
-    ./embed.cue:135:9
 patterns.shallow.indirect.p1.err1.j: field not allowed:
-    ./embed.cue:146:6
-    ./embed.cue:147:7
-    ./embed.cue:150:7
-    ./embed.cue:151:10
     ./embed.cue:152:10
 patterns.shallow.indirect.p1.err2.j: field not allowed:
-    ./embed.cue:146:6
-    ./embed.cue:147:7
-    ./embed.cue:150:7
-    ./embed.cue:154:10
     ./embed.cue:155:10
 patterns.shallow.indirect.p2.err1.j: field not allowed:
-    ./embed.cue:146:6
-    ./embed.cue:162:8
-    ./embed.cue:163:7
-    ./embed.cue:165:10
     ./embed.cue:166:10
 patterns.shallow.indirect.p2.err2.j: field not allowed:
-    ./embed.cue:146:6
-    ./embed.cue:162:8
-    ./embed.cue:163:7
-    ./embed.cue:168:10
     ./embed.cue:169:10
 patterns.shallow.indirect.p3.err1.j: field not allowed:
-    ./embed.cue:146:6
-    ./embed.cue:147:7
-    ./embed.cue:176:7
-    ./embed.cue:178:10
     ./embed.cue:179:10
 patterns.shallow.indirect.p3.err2.j: field not allowed:
-    ./embed.cue:146:6
-    ./embed.cue:147:7
-    ./embed.cue:176:7
-    ./embed.cue:181:10
     ./embed.cue:182:10
 patterns.shallow.indirect.p4.err1.j: field not allowed:
-    ./embed.cue:146:6
-    ./embed.cue:189:8
-    ./embed.cue:190:7
-    ./embed.cue:193:10
     ./embed.cue:194:10
 patterns.shallow.indirect.p4.err2.j: field not allowed:
-    ./embed.cue:146:6
-    ./embed.cue:189:8
-    ./embed.cue:190:7
-    ./embed.cue:196:10
     ./embed.cue:197:10
 patterns.shallow.single.err.j: field not allowed:
-    ./embed.cue:30:6
-    ./embed.cue:36:6
-    ./embed.cue:37:8
     ./embed.cue:38:8
-issue3924.two.out.foo: invalid value {disallowed:_|_(issue3924.two.out.foo.disallowed: field not allowed),allowed?:string} (does not satisfy matchN): 0 matched, expected 1:
-    ./ellipsis.cue:52:9
-    ./ellipsis.cue:50:14
-    ./ellipsis.cue:52:16
-    ./ellipsis.cue:59:23
 issue3924.two.out.foo.disallowed: field not allowed:
     ./ellipsis.cue:52:9
-    ./ellipsis.cue:50:3
-    ./ellipsis.cue:50:14
-    ./ellipsis.cue:55:15
-    ./ellipsis.cue:59:7
     ./ellipsis.cue:59:23
 
 Result:
@@ -364,10 +109,6 @@
         a: (string){ "ok" }
         b: (_|_){
           // [eval] issue3778.full.z.b: field not allowed:
-          //     ./ellipsis.cue:2:6
-          //     ./ellipsis.cue:3:6
-          //     ./ellipsis.cue:3:13
-          //     ./ellipsis.cue:4:5
           //     ./ellipsis.cue:6:3
         }
       }
@@ -395,9 +136,6 @@
         // [eval]
         foo: (_|_){
           // [eval] issue1867.one.x.foo: field not allowed:
-          //     ./ellipsis.cue:20:12
-          //     ./ellipsis.cue:21:7
-          //     ./ellipsis.cue:22:5
           //     ./ellipsis.cue:23:5
         }
       }
@@ -414,10 +152,6 @@
         // [eval]
         foo: (_|_){
           // [eval] issue1867.two.x.foo: field not allowed:
-          //     ./ellipsis.cue:26:6
-          //     ./ellipsis.cue:27:9
-          //     ./ellipsis.cue:28:10
-          //     ./ellipsis.cue:29:5
           //     ./ellipsis.cue:30:5
         }
       }
@@ -432,9 +166,6 @@
         // [eval]
         foo: (_|_){
           // [eval] issue1867.three.x.foo: field not allowed:
-          //     ./ellipsis.cue:34:15
-          //     ./ellipsis.cue:35:10
-          //     ./ellipsis.cue:36:5
           //     ./ellipsis.cue:37:5
         }
       }
@@ -455,10 +186,6 @@
           // [eval]
           disallowed: (_|_){
             // [eval] issue3924.one.out.foo.disallowed: field not allowed:
-            //     ./ellipsis.cue:42:3
-            //     ./ellipsis.cue:42:14
-            //     ./ellipsis.cue:44:16
-            //     ./ellipsis.cue:46:7
             //     ./ellipsis.cue:46:23
           }
           allowed?: (string){ string }
@@ -474,33 +201,20 @@
       }
       out: (_|_){
         // [eval]
-        #job: (#struct){
-          allowed?: (string){ string }
-        }
-        foo: (_|_){
-          // [eval] issue3924.two.out.foo: invalid value {disallowed:_|_(issue3924.two.out.foo.disallowed: field not allowed),allowed?:string} (does not satisfy matchN): 0 matched, expected 1:
-          //     ./ellipsis.cue:52:9
-          //     ./ellipsis.cue:50:14
-          //     ./ellipsis.cue:52:16
-          //     ./ellipsis.cue:59:23
-          // issue3924.two.out.foo.disallowed: field not allowed:
-          //     ./ellipsis.cue:52:9
-          //     ./ellipsis.cue:50:3
-          //     ./ellipsis.cue:50:14
-          //     ./ellipsis.cue:55:15
-          //     ./ellipsis.cue:59:7
+        foo: (_|_){
+          // [eval] issue3924.two.out.foo.disallowed: field not allowed:
+          //     ./ellipsis.cue:52:9
           //     ./ellipsis.cue:59:23
           disallowed: (_|_){
             // [eval] issue3924.two.out.foo.disallowed: field not allowed:
             //     ./ellipsis.cue:52:9
-            //     ./ellipsis.cue:50:3
-            //     ./ellipsis.cue:50:14
-            //     ./ellipsis.cue:55:15
-            //     ./ellipsis.cue:59:7
             //     ./ellipsis.cue:59:23
           }
           allowed?: (string){ string }
         }
+        #job: (#struct){
+          allowed?: (string){ string }
+        }
       }
     }
   }
@@ -515,13 +229,13 @@
         }
       }
       #Extended: (#struct){
-        name: (string){ "base" }
-        type: (string){ "extended" }
-        items: (#struct){
-          "my-item": (#struct){
-            name: (string){ "my-item" }
-          }
-        }
+        type: (string){ "extended" }
+        items: (#struct){
+          "my-item": (#struct){
+            name: (string){ "my-item" }
+          }
+        }
+        name: (string){ "base" }
       }
       broken: (#struct){
         name: (string){ "base" }
@@ -533,13 +247,13 @@
         }
       }
       works: (#struct){
-        name: (string){ "base" }
-        type: (string){ "extended" }
-        items: (#struct){
-          "my-item": (#struct){
-            name: (string){ "my-item" }
-          }
-        }
+        type: (string){ "extended" }
+        items: (#struct){
+          "my-item": (#struct){
+            name: (string){ "my-item" }
+          }
+        }
+        name: (string){ "base" }
       }
     }
   }
@@ -563,9 +277,6 @@
           // [eval]
           j: (_|_){
             // [eval] patterns.shallow.single.err.j: field not allowed:
-            //     ./embed.cue:30:6
-            //     ./embed.cue:36:6
-            //     ./embed.cue:37:8
             //     ./embed.cue:38:8
           }
         }
@@ -583,11 +294,7 @@
             // [eval]
             j: (_|_){
               // [eval] patterns.shallow.and.p1.err.j: field not allowed:
-              //     ./embed.cue:30:6
-              //     ./embed.cue:31:6
-              //     ./embed.cue:45:6
-              //     ./embed.cue:45:11
-              //     ./embed.cue:47:8
+              //     ./embed.cue:31:6
               //     ./embed.cue:48:8
             }
           }
@@ -603,11 +310,7 @@
             // [eval]
             j: (_|_){
               // [eval] patterns.shallow.and.p2.err.j: field not allowed:
-              //     ./embed.cue:30:6
-              //     ./embed.cue:31:6
-              //     ./embed.cue:55:6
-              //     ./embed.cue:55:11
-              //     ./embed.cue:56:8
+              //     ./embed.cue:31:6
               //     ./embed.cue:57:8
             }
           }
@@ -626,12 +329,7 @@
             // [eval]
             j: (_|_){
               // [eval] patterns.shallow.andEmbed.p1.err.j: field not allowed:
-              //     ./embed.cue:30:6
-              //     ./embed.cue:31:6
-              //     ./embed.cue:64:6
-              //     ./embed.cue:64:8
-              //     ./embed.cue:64:13
-              //     ./embed.cue:66:8
+              //     ./embed.cue:31:6
               //     ./embed.cue:67:8
             }
           }
@@ -647,12 +345,7 @@
             // [eval]
             j: (_|_){
               // [eval] patterns.shallow.andEmbed.p2.err.j: field not allowed:
-              //     ./embed.cue:30:6
-              //     ./embed.cue:31:6
-              //     ./embed.cue:74:6
-              //     ./embed.cue:74:8
-              //     ./embed.cue:74:13
-              //     ./embed.cue:75:8
+              //     ./embed.cue:31:6
               //     ./embed.cue:76:8
             }
           }
@@ -683,81 +376,34 @@
           }
         }
       }
-      andOrEmbed: (_|_){
-        // [eval]
-        t1: (_|_){
-          // [eval]
-          p1: (_|_){
-            // [eval]
-            X: (#struct){
-            }
-            err1: (_|_){
-              // [eval]
-              j: (_|_){
-                // [eval] patterns.shallow.andOrEmbed.t1.p1.err1.j: field not allowed:
-                //     ./embed.cue:30:6
-                //     ./embed.cue:31:6
-                //     ./embed.cue:32:6
-                //     ./embed.cue:33:6
-                //     ./embed.cue:103:6
-                //     ./embed.cue:104:4
-                //     ./embed.cue:104:9
-                //     ./embed.cue:105:4
-                //     ./embed.cue:105:9
-                //     ./embed.cue:107:9
-                //     ./embed.cue:108:9
-              }
-            }
-            ok1: (#struct){
-              k: (int){ 3 }
-            }
-          }
-          p2: (_|_){
-            // [eval]
-            X: (#struct){
-            }
-            err1: (_|_){
-              // [eval]
-              j: (_|_){
-                // [eval] patterns.shallow.andOrEmbed.t1.p2.err1.j: field not allowed:
-                //     ./embed.cue:30:6
-                //     ./embed.cue:31:6
-                //     ./embed.cue:32:6
-                //     ./embed.cue:33:6
-                //     ./embed.cue:116:6
-                //     ./embed.cue:117:4
-                //     ./embed.cue:117:9
-                //     ./embed.cue:118:4
-                //     ./embed.cue:118:9
-                //     ./embed.cue:120:9
-                //     ./embed.cue:121:9
-              }
-            }
-            ok1: (#struct){
-              k: (int){ 3 }
-            }
-          }
-        }
-        t2: (_|_){
-          // [eval]
-          X: (#struct){
-          }
-          err1: (_|_){
-            // [eval]
-            j: (_|_){
-              // [eval] patterns.shallow.andOrEmbed.t2.err1.j: field not allowed:
-              //     ./embed.cue:30:6
-              //     ./embed.cue:31:6
-              //     ./embed.cue:32:6
-              //     ./embed.cue:33:6
-              //     ./embed.cue:129:6
-              //     ./embed.cue:130:4
-              //     ./embed.cue:130:9
-              //     ./embed.cue:131:4
-              //     ./embed.cue:131:9
-              //     ./embed.cue:134:9
-              //     ./embed.cue:135:9
-            }
+      andOrEmbed: (struct){
+        t1: (struct){
+          p1: (struct){
+            X: (#struct){
+            }
+            err1: (#struct){
+              j: (int){ 3 }
+            }
+            ok1: (#struct){
+              k: (int){ 3 }
+            }
+          }
+          p2: (struct){
+            X: (#struct){
+            }
+            err1: (#struct){
+              j: (int){ 3 }
+            }
+            ok1: (#struct){
+              k: (int){ 3 }
+            }
+          }
+        }
+        t2: (struct){
+          X: (#struct){
+          }
+          err1: (#struct){
+            j: (int){ 3 }
           }
           ok1: (#struct){
             k: (int){ 3 }
@@ -781,10 +427,6 @@
             // [eval]
             j: (_|_){
               // [eval] patterns.shallow.indirect.p1.err1.j: field not allowed:
-              //     ./embed.cue:146:6
-              //     ./embed.cue:147:7
-              //     ./embed.cue:150:7
-              //     ./embed.cue:151:10
               //     ./embed.cue:152:10
             }
           }
@@ -792,10 +434,6 @@
             // [eval]
             j: (_|_){
               // [eval] patterns.shallow.indirect.p1.err2.j: field not allowed:
-              //     ./embed.cue:146:6
-              //     ./embed.cue:147:7
-              //     ./embed.cue:150:7
-              //     ./embed.cue:154:10
               //     ./embed.cue:155:10
             }
           }
@@ -813,10 +451,6 @@
             // [eval]
             j: (_|_){
               // [eval] patterns.shallow.indirect.p2.err1.j: field not allowed:
-              //     ./embed.cue:146:6
-              //     ./embed.cue:162:8
-              //     ./embed.cue:163:7
-              //     ./embed.cue:165:10
               //     ./embed.cue:166:10
             }
           }
@@ -824,10 +458,6 @@
             // [eval]
             j: (_|_){
               // [eval] patterns.shallow.indirect.p2.err2.j: field not allowed:
-              //     ./embed.cue:146:6
-              //     ./embed.cue:162:8
-              //     ./embed.cue:163:7
-              //     ./embed.cue:168:10
               //     ./embed.cue:169:10
             }
           }
@@ -843,10 +473,6 @@
             // [eval]
             j: (_|_){
               // [eval] patterns.shallow.indirect.p3.err1.j: field not allowed:
-              //     ./embed.cue:146:6
-              //     ./embed.cue:147:7
-              //     ./embed.cue:176:7
-              //     ./embed.cue:178:10
               //     ./embed.cue:179:10
             }
           }
@@ -854,10 +480,6 @@
             // [eval]
             j: (_|_){
               // [eval] patterns.shallow.indirect.p3.err2.j: field not allowed:
-              //     ./embed.cue:146:6
-              //     ./embed.cue:147:7
-              //     ./embed.cue:176:7
-              //     ./embed.cue:181:10
               //     ./embed.cue:182:10
             }
           }
@@ -875,10 +497,6 @@
             // [eval]
             j: (_|_){
               // [eval] patterns.shallow.indirect.p4.err1.j: field not allowed:
-              //     ./embed.cue:146:6
-              //     ./embed.cue:189:8
-              //     ./embed.cue:190:7
-              //     ./embed.cue:193:10
               //     ./embed.cue:194:10
             }
           }
@@ -886,10 +504,6 @@
             // [eval]
             j: (_|_){
               // [eval] patterns.shallow.indirect.p4.err2.j: field not allowed:
-              //     ./embed.cue:146:6
-              //     ./embed.cue:189:8
-              //     ./embed.cue:190:7
-              //     ./embed.cue:196:10
               //     ./embed.cue:197:10
             }
           }
@@ -927,12 +541,7 @@
       }
       single: (_|_){
         // [eval]
-        X: (#struct){
-          x: (#struct){
-            y: (#struct){
-            }
-          }
-        }
+        X: ~(patterns.nested.#a)
         err: (_|_){
           // [eval]
           x: (_|_){
@@ -941,9 +550,6 @@
               // [eval]
               j: (_|_){
                 // [eval] patterns.nested.single.err.x.y.j: field not allowed:
-                //     ./embed.cue:206:12
-                //     ./embed.cue:212:6
-                //     ./embed.cue:213:8
                 //     ./embed.cue:214:14
               }
             }
@@ -975,11 +581,7 @@
                 // [eval]
                 j: (_|_){
                   // [eval] patterns.nested.and.p1.err.x.y.j: field not allowed:
-                  //     ./embed.cue:206:12
-                  //     ./embed.cue:207:12
-                  //     ./embed.cue:221:6
-                  //     ./embed.cue:221:11
-                  //     ./embed.cue:223:8
+                  //     ./embed.cue:207:12
                   //     ./embed.cue:224:14
                 }
               }
@@ -1009,11 +611,7 @@
                 // [eval]
                 j: (_|_){
                   // [eval] patterns.nested.and.p2.err.x.y.j: field not allowed:
-                  //     ./embed.cue:206:12
-                  //     ./embed.cue:207:12
-                  //     ./embed.cue:231:6
-                  //     ./embed.cue:231:11
-                  //     ./embed.cue:232:8
+                  //     ./embed.cue:207:12
                   //     ./embed.cue:233:14
                 }
               }
@@ -1046,11 +644,7 @@
                 // [eval]
                 j: (_|_){
                   // [eval] patterns.nested.andEmbed.p1.err.x.y.j: field not allowed:
-                  //     ./embed.cue:206:12
-                  //     ./embed.cue:207:12
-                  //     ./embed.cue:240:8
-                  //     ./embed.cue:240:13
-                  //     ./embed.cue:242:8
+                  //     ./embed.cue:207:12
                   //     ./embed.cue:243:14
                 }
               }
@@ -1080,11 +674,7 @@
                 // [eval]
                 j: (_|_){
                   // [eval] patterns.nested.andEmbed.p2.err.x.y.j: field not allowed:
-                  //     ./embed.cue:206:12
-                  //     ./embed.cue:207:12
-                  //     ./embed.cue:250:8
-                  //     ./embed.cue:250:13
-                  //     ./embed.cue:251:8
+                  //     ./embed.cue:207:12
                   //     ./embed.cue:252:14
                 }
               }
@@ -1145,143 +735,78 @@
           }
         }
       }
-      andOrEmbed: (_|_){
-        // [eval]
-        t1: (_|_){
-          // [eval]
-          p1: (_|_){
-            // [eval]
-            X: (#struct){
-              x: (#struct){
-                y: (#struct){
-                }
-              }
-            }
-            err1: (_|_){
-              // [eval]
-              x: (_|_){
-                // [eval]
-                y: (_|_){
-                  // [eval]
-                  j: (_|_){
-                    // [eval] patterns.nested.andOrEmbed.t1.p1.err1.x.y.j: field not allowed:
-                    //     ./embed.cue:206:12
-                    //     ./embed.cue:207:12
-                    //     ./embed.cue:208:12
-                    //     ./embed.cue:209:12
-                    //     ./embed.cue:280:4
-                    //     ./embed.cue:280:9
-                    //     ./embed.cue:281:4
-                    //     ./embed.cue:281:9
-                    //     ./embed.cue:283:9
-                    //     ./embed.cue:284:15
-                  }
-                }
-              }
-            }
-            ok1: (#struct){
-              x: (#struct){
-                y: (#struct){
-                  k: (int){ 3 }
-                }
-              }
-            }
-          }
-          p2: (_|_){
-            // [eval]
-            X: (#struct){
-              x: (#struct){
-                y: (#struct){
-                }
-              }
-            }
-            err1: (_|_){
-              // [eval]
-              x: (_|_){
-                // [eval]
-                y: (_|_){
-                  // [eval]
-                  j: (_|_){
-                    // [eval] patterns.nested.andOrEmbed.t1.p2.err1.x.y.j: field not allowed:
-                    //     ./embed.cue:206:12
-                    //     ./embed.cue:207:12
-                    //     ./embed.cue:208:12
-                    //     ./embed.cue:209:12
-                    //     ./embed.cue:293:4
-                    //     ./embed.cue:293:9
-                    //     ./embed.cue:294:4
-                    //     ./embed.cue:294:9
-                    //     ./embed.cue:296:9
-                    //     ./embed.cue:297:15
-                  }
-                }
-              }
-            }
-            ok1: (#struct){
-              x: (#struct){
-                y: (#struct){
-                  k: (int){ 3 }
-                }
-              }
-            }
-          }
-        }
-        t2: (_|_){
-          // [eval]
-          X: (#struct){
-            x: (#struct){
-              y: (#struct){
-              }
-            }
-          }
-          err1: (_|_){
-            // [eval]
-            x: (_|_){
-              // [eval]
-              y: (_|_){
-                // [eval]
-                j: (_|_){
-                  // [eval] patterns.nested.andOrEmbed.t2.err1.x.y.j: field not allowed:
-                  //     ./embed.cue:206:12
-                  //     ./embed.cue:207:12
-                  //     ./embed.cue:208:12
-                  //     ./embed.cue:209:12
-                  //     ./embed.cue:306:4
-                  //     ./embed.cue:306:9
-                  //     ./embed.cue:307:4
-                  //     ./embed.cue:307:9
-                  //     ./embed.cue:310:9
-                  //     ./embed.cue:311:15
-                }
-              }
-            }
-          }
-          ok1: (#struct){
-            x: (#struct){
-              y: (#struct){
-                k: (int){ 3 }
-              }
-            }
-          }
-          ok2: (_|_){
-            // [eval]
-            x: (_|_){
-              // [eval]
-              y: (_|_){
-                // [eval]
-                p: (_|_){
-                  // [eval] patterns.nested.andOrEmbed.t2.ok2.x.y.p: field not allowed:
-                  //     ./embed.cue:206:12
-                  //     ./embed.cue:207:12
-                  //     ./embed.cue:208:12
-                  //     ./embed.cue:209:12
-                  //     ./embed.cue:306:4
-                  //     ./embed.cue:306:9
-                  //     ./embed.cue:307:4
-                  //     ./embed.cue:307:9
-                  //     ./embed.cue:316:8
-                  //     ./embed.cue:317:14
-                }
+      andOrEmbed: (struct){
+        t1: (struct){
+          p1: (struct){
+            X: (#struct){
+              x: (#struct){
+                y: (#struct){
+                }
+              }
+            }
+            err1: (#struct){
+              x: (#struct){
+                y: (#struct){
+                  j: (int){ 3 }
+                }
+              }
+            }
+            ok1: (#struct){
+              x: (#struct){
+                y: (#struct){
+                  k: (int){ 3 }
+                }
+              }
+            }
+          }
+          p2: (struct){
+            X: (#struct){
+              x: (#struct){
+                y: (#struct){
+                }
+              }
+            }
+            err1: (#struct){
+              x: (#struct){
+                y: (#struct){
+                  j: (int){ 3 }
+                }
+              }
+            }
+            ok1: (#struct){
+              x: (#struct){
+                y: (#struct){
+                  k: (int){ 3 }
+                }
+              }
+            }
+          }
+        }
+        t2: (struct){
+          X: (#struct){
+            x: (#struct){
+              y: (#struct){
+              }
+            }
+          }
+          err1: (#struct){
+            x: (#struct){
+              y: (#struct){
+                j: (int){ 3 }
+              }
+            }
+          }
+          ok1: (#struct){
+            x: (#struct){
+              y: (#struct){
+                k: (int){ 3 }
+              }
+            }
+          }
+          ok2: (#struct){
+            x: (#struct){
+              y: (#struct){
+                p: (int){ 3 }
               }
             }
           }
@@ -1303,12 +828,7 @@
         }
         p1: (_|_){
           // [eval]
-          X: (#struct){
-            x: (#struct){
-              y: (#struct){
-              }
-            }
-          }
+          X: ~(patterns.nested.indirect.#a)
           err1: (_|_){
             // [eval]
             x: (_|_){
@@ -1317,10 +837,6 @@
                 // [eval]
                 j: (_|_){
                   // [eval] patterns.nested.indirect.p1.err1.x.y.j: field not allowed:
-                  //     ./embed.cue:322:12
-                  //     ./embed.cue:323:7
-                  //     ./embed.cue:326:7
-                  //     ./embed.cue:327:10
                   //     ./embed.cue:328:16
                 }
               }
@@ -1334,10 +850,6 @@
                 // [eval]
                 j: (_|_){
                   // [eval] patterns.nested.indirect.p1.err2.x.y.j: field not allowed:
-                  //     ./embed.cue:322:12
-                  //     ./embed.cue:323:7
-                  //     ./embed.cue:326:7
-                  //     ./embed.cue:330:10
                   //     ./embed.cue:331:16
                 }
               }
@@ -1359,12 +871,7 @@
               }
             }
           }
-          X: (#struct){
-            x: (#struct){
-              y: (#struct){
-              }
-            }
-          }
+          X: ~(patterns.nested.indirect.p2.#a)
           err1: (_|_){
             // [eval]
             x: (_|_){
@@ -1373,10 +880,6 @@
                 // [eval]
                 j: (_|_){
                   // [eval] patterns.nested.indirect.p2.err1.x.y.j: field not allowed:
-                  //     ./embed.cue:322:12
-                  //     ./embed.cue:338:8
-                  //     ./embed.cue:339:7
-                  //     ./embed.cue:341:10
                   //     ./embed.cue:342:16
                 }
               }
@@ -1390,10 +893,6 @@
                 // [eval]
                 j: (_|_){
                   // [eval] patterns.nested.indirect.p2.err2.x.y.j: field not allowed:
-                  //     ./embed.cue:322:12
-                  //     ./embed.cue:338:8
-                  //     ./embed.cue:339:7
-                  //     ./embed.cue:344:10
                   //     ./embed.cue:345:16
                 }
               }
@@ -1423,10 +922,6 @@
                 // [eval]
                 j: (_|_){
                   // [eval] patterns.nested.indirect.p3.err1.x.y.j: field not allowed:
-                  //     ./embed.cue:322:12
-                  //     ./embed.cue:323:7
-                  //     ./embed.cue:352:7
-                  //     ./embed.cue:354:10
                   //     ./embed.cue:355:16
                 }
               }
@@ -1440,10 +935,6 @@
                 // [eval]
                 j: (_|_){
                   // [eval] patterns.nested.indirect.p3.err2.x.y.j: field not allowed:
-                  //     ./embed.cue:322:12
-                  //     ./embed.cue:323:7
-                  //     ./embed.cue:352:7
-                  //     ./embed.cue:357:10
                   //     ./embed.cue:358:16
                 }
               }
@@ -1479,10 +970,6 @@
                 // [eval]
                 j: (_|_){
                   // [eval] patterns.nested.indirect.p4.err1.x.y.j: field not allowed:
-                  //     ./embed.cue:322:12
-                  //     ./embed.cue:365:8
-                  //     ./embed.cue:366:7
-                  //     ./embed.cue:369:10
                   //     ./embed.cue:370:16
                 }
               }
@@ -1496,10 +983,6 @@
                 // [eval]
                 j: (_|_){
                   // [eval] patterns.nested.indirect.p4.err2.x.y.j: field not allowed:
-                  //     ./embed.cue:322:12
-                  //     ./embed.cue:365:8
-                  //     ./embed.cue:366:7
-                  //     ./embed.cue:372:10
                   //     ./embed.cue:373:16
                 }
               }
@@ -1516,7 +999,8 @@
       }
     }
   }
-  issue2241: (struct){
+  issue2241: (_|_){
+    // [eval]
     #close: (#struct){
     }
     a: (#struct){
@@ -1524,10 +1008,15 @@
         q: (int){ 2 }
       }
     }
-    b: (#struct){
-      x: (struct){
-        q: (int){ 2 }
-        r: (int){ 4 }
+    b: (_|_){
+      // [eval]
+      x: (_|_){
+        // [eval]
+        r: (_|_){
+          // [eval] issue2241.b.x.r: field not allowed:
+          //     ./embed.cue:390:8
+        }
+        q: (int){ 2 }
       }
     }
   }
@@ -1537,8 +1026,8 @@
   #A: (#struct){
     b: (int){ int }
     q: (#struct){
+      d: (int){ int }
       c: (int){ int }
-      d: (int){ int }
     }
   }
   a: (_|_){
@@ -1547,21 +1036,15 @@
     q: (_|_){
       // [eval]
       c: (int){ 2 }
-      d: (int){ int }
       e: (_|_){
         // [eval] a.q.e: field not allowed:
-        //     ./in.cue:1:5
-        //     ./in.cue:6:5
-        //     ./in.cue:7:3
-        //     ./in.cue:11:4
         //     ./in.cue:15:3
       }
+      d: (int){ int }
     }
   }
   issue852: (_|_){
     // [eval] issue852.a.Foo: field not allowed:
-    //     ./in.cue:22:6
-    //     ./in.cue:26:5
     //     ./in.cue:28:5
     #A: (#struct){
     }
@@ -1569,8 +1052,6 @@
       // [eval]
       Foo: (_|_){
         // [eval] issue852.a.Foo: field not allowed:
-        //     ./in.cue:22:6
-        //     ./in.cue:26:5
         //     ./in.cue:28:5
       }
     }
@@ -1581,8 +1062,8 @@
       foo: (int){ int }
     }
     d: (#struct){
-      key: (string){ "foo" }
       foo: (int){ 3 }
+      key: (string){ "foo" }
     }
   }
   issue3330: (struct){
@@ -1596,13 +1077,7 @@
           }
         }
         out: (#list){
-          0: (#struct){
-            let empty#1 = (#struct){
-            }
-            field: (#struct){
-              n: (int){ 3 }
-            }
-          }
+          0: ~(issue3330.let.ok.#struct)
         }
       }
     }
@@ -1631,13 +1106,7 @@
           g: (#struct){
           }
         }
-        out: (#struct){
-          field: (#struct){
-            n: (int){ 3 }
-          }
-          g: (#struct){
-          }
-        }
+        out: ~(issue3330.matthew.ok2.#struct)
         out2: (#struct){
           field: (#struct){
             n: (int){ 3 }
@@ -1658,13 +1127,7 @@
             d: (int){ 1 }
           }
         }
-        0: (#struct){
-          let b#2 = (#struct){
-          }
-          c: (#struct){
-            d: (int){ 1 }
-          }
-        }
+        0: ~(issue3331.original.ok.#A)
       }
     }
     variant1: (struct){
@@ -1677,13 +1140,7 @@
           }
         }
         0: (#list){
-          0: (#struct){
-            let b#3 = (#struct){
-            }
-            c: (#struct){
-              d: (int){ 1 }
-            }
-          }
+          0: ~(issue3331.variant1.ok.#A)
         }
       }
     }
@@ -1699,10 +1156,7 @@
               c: (int){ 2 }
             }
           }
-          zx: (#struct){
-            b: (int){ 1 }
-            c: (int){ 2 }
-          }
+          zx: ~(indirect.embed.err1.#A.x.a)
         }
         #x: (#struct){
           a: (#struct){
@@ -1714,22 +1168,11 @@
             c: (int){ 2 }
           }
         }
-        b: (#struct){
-          x: (#struct){
-            a: (#struct){
-              b: (int){ 1 }
-              c: (int){ 2 }
-            }
-          }
-          zx: (#struct){
-            b: (int){ 1 }
-            c: (int){ 2 }
-          }
-        }
-        b1: (struct){
+        b: ~(indirect.embed.err1.#A)
+        b1: (#struct){
+          d: (int){ 1 }
           b: (int){ 1 }
           c: (int){ 2 }
-          d: (int){ 1 }
         }
       }
     }
@@ -1746,22 +1189,16 @@
         }
         Y: (_|_){
           // [eval]
+          b: (#struct){
+          }
+          c: (#struct){
+          }
           a: (_|_){
             // [eval]
             e: (_|_){
               // [eval] indirect.closed.err1.Y.a.e: field not allowed:
-              //     ./reroot.cue:73:7
-              //     ./reroot.cue:74:7
               //     ./reroot.cue:75:7
-              //     ./reroot.cue:77:6
-              //     ./reroot.cue:79:7
-              //     ./reroot.cue:80:7
-              //     ./reroot.cue:82:7
-            }
-          }
-          b: (#struct){
-          }
-          c: (#struct){
+            }
           }
         }
         #X: (#struct){
@@ -1781,25 +1218,11 @@
           }
         }
       }
-      x: (#struct){
-        b: (#struct){
-        }
-        #B: (#struct){
-          c: (#struct){
-            d: (int){ 1 }
-          }
-        }
-      }
-    }
-    embed: (struct){
-      ok: (struct){
-        x: (#struct){
-          d: (#struct){
-            e: (int){ int }
-          }
-          b: (#struct){
-          }
-        }
+      x: ~(nested.ok1.#A)
+    }
+    embed: (struct){
+      ok: (struct){
+        x: ~(nested.embed.ok.#A)
         #A: (#struct){
           d: (#struct){
             e: (int){ int }
@@ -1824,69 +1247,27 @@
           // [eval]
           f: (_|_){
             // [eval] nested.err1.x.b.f: field not allowed:
-            //     ./reroot.cue:112:5
-            //     ./reroot.cue:114:6
-            //     ./reroot.cue:122:8
-            //     ./reroot.cue:123:6
+            //     ./reroot.cue:114:6
           }
           g: (_|_){
             // [eval] nested.err1.x.b.g: field not allowed:
-            //     ./reroot.cue:112:5
-            //     ./reroot.cue:114:6
-            //     ./reroot.cue:122:8
-            //     ./reroot.cue:123:6
-          }
-        }
-        v: (_|_){
-          // [eval]
-          c: (_|_){
-            // [eval]
-            f: (_|_){
-              // [eval] nested.err1.x.v.c.f: field not allowed:
-              //     ./reroot.cue:112:5
-              //     ./reroot.cue:114:6
-              //     ./reroot.cue:115:6
-              //     ./reroot.cue:117:7
-              //     ./reroot.cue:117:11
-              //     ./reroot.cue:122:8
-              //     ./reroot.cue:123:6
-            }
-            g: (int){ 1 }
-            d: (_|_){
-              // [eval] nested.err1.x.v.c.d: field not allowed:
-              //     ./reroot.cue:112:5
-              //     ./reroot.cue:114:6
-              //     ./reroot.cue:115:6
-              //     ./reroot.cue:117:7
-              //     ./reroot.cue:118:5
-              //     ./reroot.cue:122:8
-              //     ./reroot.cue:123:6
-            }
-          }
-        }
+            //     ./reroot.cue:123:6
+          }
+        }
+        v: ~(nested.err1.x.#V)
         #V: (_|_){
           // [eval]
           c: (_|_){
             // [eval]
-            f: (_|_){
-              // [eval] nested.err1.x.#V.c.f: field not allowed:
-              //     ./reroot.cue:112:5
-              //     ./reroot.cue:114:6
-              //     ./reroot.cue:117:7
-              //     ./reroot.cue:117:11
-              //     ./reroot.cue:122:8
-              //     ./reroot.cue:123:6
-            }
-            g: (int){ 1 }
             d: (_|_){
               // [eval] nested.err1.x.#V.c.d: field not allowed:
-              //     ./reroot.cue:112:5
-              //     ./reroot.cue:114:6
-              //     ./reroot.cue:117:7
-              //     ./reroot.cue:118:5
-              //     ./reroot.cue:122:8
-              //     ./reroot.cue:123:6
-            }
+              //     ./reroot.cue:118:5
+            }
+            f: (_|_){
+              // [eval] nested.err1.x.#V.c.f: field not allowed:
+              //     ./reroot.cue:114:6
+            }
+            g: (int){ 1 }
           }
         }
       }
@@ -1894,16 +1275,11 @@
         b: (#struct){
           f: (int){ 1 }
         }
-        v: (#struct){
-          c: (#struct){
-            f: (int){ 1 }
-            d: (int){ 1 }
-          }
-        }
+        v: ~(nested.err1.#A.#V)
         #V: (#struct){
           c: (#struct){
-            f: (int){ 1 }
-            d: (int){ 1 }
+            d: (int){ 1 }
+            f: (int){ 1 }
           }
         }
       }
@@ -1926,14 +1302,12 @@
           // [eval]
           g: (_|_){
             // [eval] nested.err2.x.b.g: field not allowed:
-            //     ./reroot.cue:128:6
-            //     ./reroot.cue:136:5
             //     ./reroot.cue:137:8
           }
         }
         c: (#struct){
+          d: (int){ 1 }
           g: (int){ 1 }
-          d: (int){ 1 }
         }
       }
     }
@@ -1946,11 +1320,11 @@
         }
       }
     }
-    err1: (struct){
+    err1: (#struct){
       name: (string){ "a" }
       age1: (int){ 5 }
     }
-    err2: (struct){
+    err2: (#struct){
       name: (string){ "a" }
       age2: (int){ 5 }
     }
@@ -2097,20 +1471,20 @@
         }
       }
       original: (struct){
-        Y: (struct){
-          b: (struct){
-            c: (string){ "v1" }
-          }
-        }
-        out: (struct){
-          b: (struct){
+        Y: (#struct){
+          b: (#struct){
+            c: (string){ "v1" }
+          }
+        }
+        out: (#struct){
+          b: (#struct){
             c: (string){ "v1" }
           }
         }
       }
       moreInlining: (struct){
-        out: (struct){
-          b: (struct){
+        out: (#struct){
+          b: (#struct){
             c: (string){ "v1" }
           }
         }
@@ -2134,8 +1508,8 @@
           empty: (#struct){
           }
         }
-        out: (struct){
-          b: (struct){
+        out: (#struct){
+          b: (#struct){
             c: (string){ "v1" }
           }
         }
@@ -2152,13 +1526,13 @@
           empty: (#struct){
           }
         }
-        Y: (struct){
-          c: (struct){
-            d: (string){ "v1" }
-          }
-        }
-        Z: (struct){
-          c: (struct){
+        Y: (#struct){
+          c: (#struct){
+            d: (string){ "v1" }
+          }
+        }
+        Z: (#struct){
+          c: (#struct){
             d: (string){ "v1" }
           }
         }
-- diff/todo/p2 --
Positions / reordering
-- diff/explanation --
inline.err*.age*: fields are now correctly not allowed.
patterns.*.andOrEmbed.t2.ok2: erroneous in V2
mixInDef: arguably should all be erroneous, but definitely refOutside.
indirect.embed: now correctly fails for V3.
issue2241: now correctly fails for V3.
-- out/compile --
--- ellipsis.cue
{
  issue3778: {
    full: {
      #x: {
        a?: string
      }
      #y: (〈0;#x〉 & {
        ...
      })
      z: (〈0;#y〉 & {
        a: "ok"
        b: "something"
      })
    }
  }
  issue3778: {
    keepOpen: {
      #x: {
        a?: string
        ...
      }
      #y: (〈0;#x〉 & {
        ...
      })
      z: (〈0;#y〉 & {
        a: "ok"
        b: "something"
      })
    }
  }
  issue1867: {
    one: {
      #T: close({})
      #T: {
        ...
      }
      x: 〈0;#T〉
      x: {
        foo: "foo"
      }
    }
  }
  issue1867: {
    two: {
      #S: {}
      #T: {
        s: 〈1;#S〉
      }
      #T: {
        s: {
          ...
        }
      }
      x: 〈0;#T〉.s
      x: {
        foo: "foo"
      }
    }
  }
  issue1867: {
    three: {
      #T: {
        s: close({})
      }
      #T: {
        s: {
          ...
        }
      }
      x: 〈0;#T〉.s
      x: {
        foo: "foo"
      }
    }
  }
  issue3924: {
    one: {
      #Schema: {
        ...
        {
          [string]: 〈2;#SchemaInner〉
        }
      }
      #SchemaInner: {
        allowed?: string
      }
      out: (〈0;#Schema〉 & {
        foo: {
          disallowed: "foo"
        }
      })
    }
  }
  issue3924: {
    two: {
      #Schema: {
        {
          [string]: 〈1;#job〉
        }
        #job: (matchN(1, [
          {
            other?: string
            ...
          },
        ]) & close({
          allowed?: string
        }))
      }
      out: (〈0;#Schema〉 & {
        foo: {
          disallowed: "bar"
        }
      })
    }
  }
}
--- embed.cue
{
  issue3325: {
    ok: {
      #Items: {
        [string]: {
          name: 〈1;-〉
        }
      }
      #Base: {
        name: "base"
        type: string
        items: 〈1;#Items〉
      }
      #Extended: (〈0;#Base〉 & {
        type: "extended"
        items: {
          "my-item": {}
        }
      })
      broken: {
        〈1;#Base〉
        〈1;#Extended〉
      }
      works: {
        〈1;#Extended〉
        〈1;#Base〉
      }
    }
  }
  patterns: {
    shallow: {
      #a: {
        [>="k"]: int
      }
      #b: {
        [<="m"]: int
      }
      #c: {
        [>="w"]: int
      }
      #d: {
        [<="y"]: int
      }
      single: {
        X: 〈1;#a〉
        err: 〈0;X〉
        err: {
          j: 3
        }
        ok: 〈0;X〉
        ok: {
          k: 3
        }
      }
      and: {
        p1: {
          X: (〈2;#a〉 & 〈2;#b〉)
          err: 〈0;X〉
          err: {
            j: 3
          }
          ok: 〈0;X〉
          ok: {
            k: 3
          }
        }
      }
      and: {
        p2: {
          X: (〈2;#b〉 & 〈2;#a〉)
          err: 〈0;X〉
          err: {
            j: 3
          }
          ok: 〈0;X〉
          ok: {
            k: 3
          }
        }
      }
      andEmbed: {
        p1: {
          X: {
            (〈3;#a〉 & 〈3;#b〉)
          }
          err: 〈0;X〉
          err: {
            j: 3
          }
          ok: 〈0;X〉
          ok: {
            k: 3
          }
        }
      }
      andEmbed: {
        p2: {
          X: {
            (〈3;#b〉 & 〈3;#a〉)
          }
          err: 〈0;X〉
          err: {
            j: 3
          }
          ok: 〈0;X〉
          ok: {
            k: 3
          }
        }
      }
      orEmbed: {
        p1: {
          X: {
            〈3;#a〉
            〈3;#b〉
          }
          ok1: 〈0;X〉
          ok1: {
            j: 3
          }
          ok2: 〈0;X〉
          ok2: {
            k: 3
          }
        }
      }
      orEmbed: {
        p2: {
          X: {
            〈3;#b〉
            〈3;#a〉
          }
          ok1: 〈0;X〉
          ok1: {
            j: 3
          }
          ok2: 〈0;X〉
          ok2: {
            k: 3
          }
        }
      }
      andOrEmbed: {
        t1: {
          p1: {
            X: {
              (〈4;#a〉 & 〈4;#b〉)
              (〈4;#c〉 & 〈4;#d〉)
            }
            err1: 〈0;X〉
            err1: {
              j: 3
            }
            ok1: 〈0;X〉
            ok1: {
              k: 3
            }
          }
        }
      }
      andOrEmbed: {
        t1: {
          p2: {
            X: {
              (〈4;#c〉 & 〈4;#d〉)
              (〈4;#a〉 & 〈4;#b〉)
            }
            err1: 〈0;X〉
            err1: {
              j: 3
            }
            ok1: 〈0;X〉
            ok1: {
              k: 3
            }
          }
        }
      }
      andOrEmbed: {
        t2: {
          X: {
            (〈3;#a〉 & 〈3;#b〉)
            (〈3;#c〉 & 〈3;#d〉)
            ["p"]: int
          }
          err1: 〈0;X〉
          err1: {
            j: 3
          }
          ok1: 〈0;X〉
          ok1: {
            k: 3
          }
          ok2: 〈0;X〉
          ok2: {
            p: 3
          }
        }
      }
      indirect: {
        a: {
          [>="k"]: int
        }
        #a: 〈0;a〉
        p1: {
          X: 〈1;#a〉
          err1: 〈0;X〉
          err1: {
            j: 3
          }
          err2: (〈0;X〉 & _|_(no sharing))
          err2: {
            j: 3
          }
          ok: 〈0;X〉
          ok: {
            k: 3
          }
        }
        p2: {
          #a: (〈1;a〉 & _|_(no sharing))
          X: 〈0;#a〉
          err1: 〈0;X〉
          err1: {
            j: 3
          }
          err2: (〈0;X〉 & _|_(no sharing))
          err2: {
            j: 3
          }
          ok: 〈0;X〉
          ok: {
            k: 3
          }
        }
        p3: {
          X: (〈1;#a〉 & _|_(no sharing))
          err1: 〈0;X〉
          err1: {
            j: 3
          }
          err2: (〈0;X〉 & _|_(no sharing))
          err2: {
            j: 3
          }
          ok: 〈0;X〉
          ok: {
            k: 3
          }
        }
        p4: {
          #a: (〈1;a〉 & _|_(no sharing))
          X: 〈0;#a〉
          X: (〈0;#a〉 & _|_(no sharing))
          err1: 〈0;X〉
          err1: {
            j: 3
          }
          err2: (〈0;X〉 & _|_(no sharing))
          err2: {
            j: 3
          }
          ok: 〈0;X〉
          ok: {
            k: 3
          }
        }
      }
    }
  }
  patterns: {
    nested: {
      #a: {
        x: {
          y: {
            [>="k"]: int
          }
        }
      }
      #b: {
        x: {
          y: {
            [<="m"]: int
          }
        }
      }
      #c: {
        x: {
          y: {
            [>="w"]: int
          }
        }
      }
      #d: {
        x: {
          y: {
            [<="y"]: int
          }
        }
      }
      single: {
        X: 〈1;#a〉
        err: 〈0;X〉
        err: {
          x: {
            y: {
              j: 3
            }
          }
        }
        ok: 〈0;X〉
        ok: {
          x: {
            y: {
              k: 3
            }
          }
        }
      }
      and: {
        p1: {
          X: (〈2;#a〉 & 〈2;#b〉)
          err: 〈0;X〉
          err: {
            x: {
              y: {
                j: 3
              }
            }
          }
          ok: 〈0;X〉
          ok: {
            x: {
              y: {
                k: 3
              }
            }
          }
        }
      }
      and: {
        p2: {
          X: (〈2;#b〉 & 〈2;#a〉)
          err: 〈0;X〉
          err: {
            x: {
              y: {
                j: 3
              }
            }
          }
          ok: 〈0;X〉
          ok: {
            x: {
              y: {
                k: 3
              }
            }
          }
        }
      }
      andEmbed: {
        p1: {
          X: {
            (〈3;#a〉 & 〈3;#b〉)
          }
          err: 〈0;X〉
          err: {
            x: {
              y: {
                j: 3
              }
            }
          }
          ok: 〈0;X〉
          ok: {
            x: {
              y: {
                k: 3
              }
            }
          }
        }
      }
      andEmbed: {
        p2: {
          X: {
            (〈3;#b〉 & 〈3;#a〉)
          }
          err: 〈0;X〉
          err: {
            x: {
              y: {
                j: 3
              }
            }
          }
          ok: 〈0;X〉
          ok: {
            x: {
              y: {
                k: 3
              }
            }
          }
        }
      }
      orEmbed: {
        p1: {
          X: {
            〈3;#a〉
            〈3;#b〉
          }
          ok1: 〈0;X〉
          ok1: {
            x: {
              y: {
                j: 3
              }
            }
          }
          ok2: 〈0;X〉
          ok2: {
            x: {
              y: {
                k: 3
              }
            }
          }
        }
      }
      orEmbed: {
        p2: {
          X: {
            〈3;#b〉
            〈3;#a〉
          }
          ok1: 〈0;X〉
          ok1: {
            x: {
              y: {
                j: 3
              }
            }
          }
          ok2: 〈0;X〉
          ok2: {
            x: {
              y: {
                k: 3
              }
            }
          }
        }
      }
      andOrEmbed: {
        t1: {
          p1: {
            X: {
              (〈4;#a〉 & 〈4;#b〉)
              (〈4;#c〉 & 〈4;#d〉)
            }
            err1: 〈0;X〉
            err1: {
              x: {
                y: {
                  j: 3
                }
              }
            }
            ok1: 〈0;X〉
            ok1: {
              x: {
                y: {
                  k: 3
                }
              }
            }
          }
        }
      }
      andOrEmbed: {
        t1: {
          p2: {
            X: {
              (〈4;#c〉 & 〈4;#d〉)
              (〈4;#a〉 & 〈4;#b〉)
            }
            err1: 〈0;X〉
            err1: {
              x: {
                y: {
                  j: 3
                }
              }
            }
            ok1: 〈0;X〉
            ok1: {
              x: {
                y: {
                  k: 3
                }
              }
            }
          }
        }
      }
      andOrEmbed: {
        t2: {
          X: {
            (〈3;#a〉 & 〈3;#b〉)
            (〈3;#c〉 & 〈3;#d〉)
            ["p"]: int
          }
          err1: 〈0;X〉
          err1: {
            x: {
              y: {
                j: 3
              }
            }
          }
          ok1: 〈0;X〉
          ok1: {
            x: {
              y: {
                k: 3
              }
            }
          }
          ok2: 〈0;X〉
          ok2: {
            x: {
              y: {
                p: 3
              }
            }
          }
        }
      }
      indirect: {
        a: {
          x: {
            y: {
              [>="k"]: int
            }
          }
        }
        #a: 〈0;a〉
        p1: {
          X: 〈1;#a〉
          err1: 〈0;X〉
          err1: {
            x: {
              y: {
                j: 3
              }
            }
          }
          err2: (〈0;X〉 & _|_(no sharing))
          err2: {
            x: {
              y: {
                j: 3
              }
            }
          }
          ok: 〈0;X〉
          ok: {
            x: {
              y: {
                k: 3
              }
            }
          }
        }
        p2: {
          #a: (〈1;a〉 & _|_(no sharing))
          X: 〈0;#a〉
          err1: 〈0;X〉
          err1: {
            x: {
              y: {
                j: 3
              }
            }
          }
          err2: (〈0;X〉 & _|_(no sharing))
          err2: {
            x: {
              y: {
                j: 3
              }
            }
          }
          ok: 〈0;X〉
          ok: {
            x: {
              y: {
                k: 3
              }
            }
          }
        }
        p3: {
          X: (〈1;#a〉 & _|_(no sharing))
          err1: 〈0;X〉
          err1: {
            x: {
              y: {
                j: 3
              }
            }
          }
          err2: (〈0;X〉 & _|_(no sharing))
          err2: {
            x: {
              y: {
                j: 3
              }
            }
          }
          ok: 〈0;X〉
          ok: {
            x: {
              y: {
                k: 3
              }
            }
          }
        }
        p4: {
          #a: (〈1;a〉 & _|_(no sharing))
          X: 〈0;#a〉
          X: (〈0;#a〉 & _|_(no sharing))
          err1: 〈0;X〉
          err1: {
            x: {
              y: {
                j: 3
              }
            }
          }
          err2: (〈0;X〉 & _|_(no sharing))
          err2: {
            x: {
              y: {
                j: 3
              }
            }
          }
          ok: 〈0;X〉
          ok: {
            x: {
              y: {
                k: 3
              }
            }
          }
        }
      }
    }
  }
  issue2241: {
    #close: {}
    a: {
      x: {
        q: 2
      }
      〈1;#close〉
    }
    b: 〈0;a〉
    b: {
      x: {
        r: 4
      }
    }
  }
}
--- in.cue
{
  #E: {
    c: int
  }
  #A: {
    b: int
    q: {
      〈2;#E〉
      d: int
    }
  }
  a: (〈0;#A〉 & {
    b: 3
    q: {
      c: 2
      e: 43
    }
  })
  issue852: {
    #A: {
      [=~"^a-z$"]: string
    }
    a: 〈0;#A〉
    a: {
      Foo: "foo"
    }
    for k, v in 〈0;a〉 {
      b: {
        "\(〈2;k〉)": 〈2;v〉
      }
    }
  }
  dynamic: {
    #D: {
      key: "foo"
      〈0;key〉: int
    }
    d: (〈0;#D〉 & {
      foo: 3
    })
  }
}
--- reroot.cue
{
  issue3330: {
    let: {
      ok: {
        #struct: {
          let empty#1 = {}
          field: (null|{
            n: int
          })
          field: (〈0;let empty#1〉 & {
            n: 3
          })
        }
        out: 〈import;list〉.Concat([
          [
            〈2;#struct〉,
          ],
        ])
      }
    }
    matthew: {
      ok1: {
        #struct: {
          field: ({
            n: 3
          } & 〈0;g〉)
          g: {}
        }
        out: (〈0;#struct〉 & {})
      }
    }
    matthew: {
      ok2: {
        #struct: {
          field: ({
            n: 3
          } & 〈0;g〉)
          g: {}
        }
        out: 〈0;#struct〉
        out2: (〈0;out〉 & {})
      }
    }
  }
  issue3331: {
    original: {
      ok: {
        #A: {
          let b#2 = {}
          c: (〈0;let b#2〉 & {
            d: 1
          })
        }
        〈import;list〉.Concat([
          [
            〈2;#A〉,
          ],
        ])
      }
    }
    variant1: {
      ok: {
        #A: {
          let b#3 = {}
          c: (〈0;let b#3〉 & {
            d: 1
          })
        }
        [
          [
            〈2;#A〉,
          ],
        ]
      }
    }
  }
  indirect: {
    embed: {
      err1: {
        #A: {
          x: {
            〈2;#x〉
            〈2;#y〉
          }
          zx: 〈0;x〉.a
        }
        #x: {
          a: {
            b: 1
          }
        }
        #y: {
          a: {
            c: 2
          }
        }
        b: 〈0;#A〉
        b1: 〈0;b〉.zx
        b1: {
          d: 1
        }
      }
    }
    closed: {
      err1: {
        X: {
          a: 〈0;b〉
          b: {}
          a: {
            e: 1
          }
        }
        Y: 〈0;X〉
        Y: {
          b: 〈0;c〉
          c: 〈1;#X〉
        }
        #X: {}
      }
    }
  }
  nested: {
    ok1: {
      #A: {
        b: {}
        #B: {
          c: (〈1;b〉 & {
            d: 1
          })
        }
      }
      x: 〈0;#A〉
    }
  }
  nested: {
    embed: {
      ok: {
        x: 〈0;#A〉
        #A: {
          〈1;k〉
        }
        k: {
          d: (〈0;b〉 & {
            e: int
          })
          b: {}
        }
      }
    }
  }
  nested: {
    err1: {
      x: 〈0;#A〉
      #A: {
        b: {
          f: 1
        }
        v: 〈0;#V〉
        #V: {
          c: (〈1;b〉 & {
            d: 1
          })
        }
      }
      x: {
        b: 〈1;#B〉
      }
      #B: {
        g: 1
      }
    }
  }
  nested: {
    err2: {
      #A: {
        b: {}
        c: (〈0;b〉 & {
          d: 1
        })
      }
      x: 〈0;#A〉
      x: {
        b: {
          g: 1
        }
      }
    }
  }
  inline: {
    #x: {
      y: {
        z?: {
          name: string
        }
      }
    }
    err1: ((〈0;#x〉 & {
      y: {
        z: _
      }
    }).y.z & {
      name: "a"
      age1: 5
    })
    err2: ((〈0;#x〉.y & {
      z: _
    }).z & {
      name: "a"
      age2: 5
    })
  }
  mixInDef: {
    refInside: {
      #x: {
        b: {
          c: {
            d: {}
            e: {
              f: {}
            }
          }
        }
      }
      a: 〈0;#x〉
      a: {
        b: {
          c: {
            d: {}
          }
        }
      }
      a: {
        b: {
          c: {
            e: 〈1;c〉.d
          }
        }
      }
    }
    refEdge: {
      #x: {
        c: {
          d: {}
          e: {
            f: {}
          }
        }
      }
      a: 〈0;#x〉
      a: {
        c: {
          d: {}
        }
      }
      a: {
        c: {
          e: 〈1;c〉.d
        }
      }
    }
    refOutside: {
      #x: {
        c: {
          d: {}
          e: {
            f: {}
          }
        }
      }
      a: 〈0;#x〉
      a: {
        c: {
          d: {}
        }
      }
      a: {
        c: {
          e: 〈2;a〉.c.d
        }
      }
    }
  }
  issue3601: {
    original: {
      out: {
        〈1;#Transform〉.output
      }
      #Transform: {
        output: (〈1;#Patch〉 & {}).output
      }
      #Patch: {
        target: {}
        output: {
          foo: {
            final: 〈2;target〉
            final: {
              version: "v1"
            }
          }
        }
      }
    }
  }
  issue3601: {
    originalNoShare: {
      out: {
        〈1;#Transform〉.output
      }
      #Transform: {
        output: (〈1;#Patch〉 & _|_(no sharing)).output
      }
      #Patch: {
        target: {}
        output: {
          foo: {
            final: 〈2;target〉
            final: {
              version: "v1"
            }
          }
        }
      }
    }
  }
  issue3601: {
    reduced: {
      #X: {
        a: {
          b: {
            c: "v1"
          }
        }
        a: {
          b: 〈1;empty〉
        }
        empty: {}
      }
      original: {
        Y: (〈1;#X〉 & _|_(no sharing)).a
        out: (〈0;Y〉 & _|_(no sharing))
      }
      moreInlining: {
        out: ((〈1;#X〉 & {}).a & {})
      }
      noInline: {
        Y: (〈1;#X〉 & _|_(no sharing))
        Z: (〈0;Y〉 & _|_(no sharing))
        out: (〈0;Z〉.a & _|_(no sharing))
      }
      moreNesting: {
        #X: {
          a: {
            b: {
              c: {
                d: "v1"
              }
            }
          }
          a: {
            b: {
              c: 〈2;empty〉
            }
          }
          empty: {}
        }
        Y: (〈0;#X〉.a & _|_(no sharing)).b
        Z: (〈0;Y〉 & _|_(no sharing))
      }
    }
  }
}
--- validation.cue
{
  issue3332: {
    #def: {
      field: 〈import;list〉.MinItems(1)
    }
    use: (〈0;#def〉 & {
      field: [
        "value",
      ]
    })
  }
}
