# Working set of tests that unit test specifics of the aspect of the
# comprehension algorithm that pushes down evaluation to the arcs.

-- in.cue --
linkChildren: {
	w: 1
	v: {
		x: 1
		if true {
			y: 1
			if true {
				z: 1

				rw: w
				rx: x
				ry: y
				rz: z

				n1a: na: [w, x, y, z]
				n2a: n1a: na: [w, x, y, z]
				n2z: n1z: nz: z
			}
		}
	}
}

fail: {
	a: {
		// Condition of comprehensions must still hold after its evaluation.
		//
		// `b` is not defined, causing this if comprehension to evaluate to
		// true. However, after inserting the corresponding result in curly
		// braces, the condition would be true. This is not allowed.
		if a.b == _|_ {
			b: 1
		}
	}
}

embed: {
	fail1: #C1
	#C1: {
		// TODO(errors): don't include all positions of p in the normal list of
		// positions, or rather categorize the positions to show:
		// 1) position of denied fields
		// 2) position of structs that deny them
		// 3) points at which those structs where mixed in (perhaps as tree)
		// 4) conditionals that could enable allowing a field.
		if false {
			p: _
		}
	}
	fail1: p: "foo" // this should fail, as p is not present.


	success2: #C2
	#C2: {
		if true {
			p: _
		}
	}
	success2: p: "foo" // this succeeds as p is present.

	success3: #C3
	#C3: {}
	success3: {
		if false {
			// p does not exist in success3, but it is okay, as it is not added.
			p: q: 1
		}
	}

	success4: {
		#X: y: string
		x: y: string
		x: {
			for _ in ["iter-once"] {
				#X
				if false {
					y: "foo"
				}
			}
		}
	}

	fail4: #C4
	#C4: {}
	fail4: {
		if true {
			// error as p is not allowed in fail4
			p: q: 1
		}
	}

	incomplete5: {
		a: bool
		if a {
			p: q: 1
		}
	}

	incomplete6: {
		if false {
			p: 1
		}
		p: q + 1
		q: int
	}
	incomplete7: {
		p: q + 1
		q: int
		if false {
			q: 1 // do not inadvertently pick up a void arc.
		}
	}
}

// Mix of both dynamic and static fields.
mixedFieldsSuccess: {
	a: {
		for _, s in ["foo"] {
			"\(s)": 1
			X: 1
		}
	}

	b: #Def: {
		for _, s in ["foo"] {
			"\(s)": 1
			X: 1
		}
	}
	b: x: b.#Def
	b: x: X: _
	b: x: foo: _

	c: #Def: {
		X:   int
		foo: int
	}
	c: x: c.#Def
	c: x: {
		for _, s in ["foo"] {
			"\(s)": 1
			X: 1
		}
	}
}

// fieldMismatch tests that an embedded scalar cannot be mixed with regular
// fields, even if they are added by a comprehension.
fieldMismatch: {
	a: {
		2
		if true {
			x: 3
		}
	}
}

// b12aStructCycle presents a case that can easily lead to stack overflow in
// a naive implementation. It corresponds to test b12a in structural.txtar.
noStackOverflowStructCycle: {
	#list: {
		tail: #list

		if tail != null {
			sum: tail.sum
		}
	}

	list: {
		tail: list

		if tail != null {
			sum: tail.sum
		}
	}
}


// #a is incomplete, but the missing values are provided by x.
provideIncompleteSuccess: {
	t1: {
		#a: {
			if b {
				c: 4
			}
			b: bool
		}
		x: (#a & {b: true}) & {c: 4}
		y: x
	}

	t2: {
		// c should be allowed
		#a: {
			if b {
				c: 4
			}
			b: true
		}

		#c: {}
		a: {
			if b {
				c: d: 4
			}
			b: true
			// d is disallowed, even though it is added by embedding.
			// TODO: this seems right, but it may be good to clarify why.
			c: #c
		}
	}
}

// voidArcs tests that fields are dropped and reference up counts are adjusted
// appropriately under various rewrite scenario.
voidArcs: {
	scopes: {
		x: 1
		a: {
			y: 2
			if true {
				b: x
				c: d: x
				e: y
				f: g: y
			}
		}
	}

	drop: {
		x: 1
		a: {
			y: 2
			if false {
				b: x
				c: d: x
				e: y
				f: g: y
			}
		}
	}
}

cyclicError: {
	a: {
		x: bool
		y: bool
		if a.x  {
			y: true
		}
		if a.y {
			x: true
		}
		b: {}
	}
	// The evaluation of `b` in `a` triggers a to be fully evaluated, which
	// is not possible because the evaluation of `a` depends on incomplete
	// values.
	c: a.b
}

midwayReferences: {
	a: {
		for i, j in {a: 1, b: 2} {
			x: y: z: (i): j
		}
		x: y: {}
	}
	b: a.x
	c: a.x.y
	d: a.x.y.z
}

// Ensure first closedness check is done after evaluation of
// comprehensions.
closedCheck: success1: {
	a: b: [string]: #D

	#D: {
		d: string
		if d != "c" {
			e: string
		}
	}

	a: b: c: {
		d: "d"
		e: "ok"
	}
}

closedCheck: success2: {
	a: b: [string]: #D

	#D: {
		d: string
		if d != "c" {
			("foo"+"bar"): string
		}
	}

	a: b: c: {
		d:      "d"
		foobar: "ok"
	}
}

closedCheck: success3: {
	a: b: [string]: #D

	#D: {
		d: string
		e: {
			if d != "c" {
				string
			}
		}
	}

	a: b: c: {
		d: "d"
		e: "ok"
	}
}

emptyComprehensionIncomplete: {
	a: {}
	b: {
		// b should be an incomplete error
		if a.b {
		}
	}
}

// voidEliminationSuccess tests that "conditional" or "void" arcs are eliminated
// if their expression does not yield any result.
voidEliminationSuccess: t1: {
	[string]: {
		b: bool
		if !b {}
	}
	if false {
		a: b: true
	}
}

voidEliminationSuccess: t2: {
	components: {
		sinks: [string]: #C & {
			kind: string
			configuration: {
				if kind != "source" {
					inputs: {
						required: true
					}
				}
			}
		}

		#C: {
			kind: string
			configuration: [string]: {
				required: bool
				if !required {
					common: bool
				}
			}
		}
	}

	components: sinks: blah: {
		kind: "source"
	}
}

voidEliminationSuccess: derefRef1: {
	a: [string]: c: [string]: E

	a: b: c: {
		if false {
			d: e: true // resolves
		}
	}

	E: {
		e: bool
		f: !e // remains incomplete
	}
}

voidEliminationSuccess: derefRef2: {
	a: [string]: c: [string]: E

	a: b: c: {
		if false {
			d: e: true // resolves
		}
	}

	E: #F
	#F: {
		e: bool
		f: !e // remains incomplete
	}
}

voidEliminationSuccess: derefDisj1: {
	a: [string]: c: [string]: E

	a: b: c: {
		if false {
			d: e: true
		}
	}

	E: {
		e: bool
		f: !e
	} | {
		g: bool
		h: !g
	}
}

voidEliminationSuccess: derefDisj2: {
	a: [string]: c: [string]: E & E

	a: b: c: {
		if false {
			d: e: true
		}
	}

	E: {
		e: bool
		f: !e
	} | {
		g: bool
		h: !g
	}
}

voidEliminationSuccess: bulk1: {
	a: b: {}
	a: [string]: {
		c: {
			e: string
			if false {
				e: ""
			}
		}
		d: c.e
	}
}

voidEliminationSuccess: opt1: {
	a: b: {}
	a: b?: {
		c: {
			e: string
			if false {
				e: ""
			}
		}
		d: c.e
	}
}

voidEliminationSuccess: noCycle1: {
	_x: a.b
	a: {
		c: h: "stream"
		b: {
			if c.g != _|_ {}
		}
		c: {
			if false {g: _}
		}
	}
}

voidEliminationSuccess: noCycle2: {
	a: {
		c: h: "stream"
		b: {
			if c.g != _|_ {}
		}
		c: {
			if false {g: _}
		}
	}
	_x: a.b
}

voidLookup: {
	a: x: z: a.y.z.void

	a: y: {
		c: _
		z: {}
	}

	a: [string]: {
		c: {
			for k, v in z {
				(k): null  // don't add this arc anywhere
			}
		}
		z: {
			if false {
				err: {}
			}
		}
	}
}


// Eliminate the top value even if there is an error (especially incomplete
// errors).
topElimination: {
	a: int
	_
	if true {
		x: a+1
	}
}

voidEliminationSuccess: drop1: {
	// Do not include x in s.
	t: {
		#ok: *true | bool
		if #ok {
			x: int
		}
	}
	s: t & {
		#ok: false
	}
}

// should be error
// issue #465
explicitDefaultError: {
	a: string | *_|_

	if a != "" {
	}
}

// Remove arcs for with no for comprehension results.
allArcsSuccess: p1: {
	x: {
		for k, _ in y {
			(k): null
		}
	}
	y: {
		if false {
			x: {}
		}
	}
}

allArcsSuccess: p2: {
	y: {
		if false {
			x: {}
		}
	}
	x: {
		for k, _ in y {
			(k): null
		}
	}
}

structShare: ok1: {
	a: [string]: E
	E: {}

	a: {
		if true {
			d: e: true // resolves
		}
	}
}

structShare: err1: {
	x: [string]: x.#E
	x: #E: {}
	if true {
		x: d: e: true
	}
}

-- issue2208.cue --
voidErrorIncomplete: {
	#Schema: [string]: {
		required: bool
		if !required {
		}
	}

	root: #Schema
	root: {
		if false {
			child: required: false
		}
	}
}

// TODO: should these always be errors, or only for cue vet?
// voidErrorFatal: pattern: {
// 	#Schema: [string]: {
// 		if "str" + 3 {
// 		}
// 	}
//
// 	root: #Schema
// 	root: {
// 		if false {
// 			child: required: false
// 		}
// 	}
// }
//
// voidErrorFatal: field: {
// 	root: {
// 		if false {
// 			child: 2 + "str"
// 		}
// 	}
// }


-- issue1759.cue --
// Tests derived from Unity.
unity: success1: {
	#Config: {
		name: string
		type: string
	}

	#AnyConfig: {
		#Config
		...
	}

	#Env: {
		name: string
		configurations: [string]: #AnyConfig
	}

	envs: "e1": #Env & {
		configurations: c1:  #Config
	}

	envs: [string]: configurations: [string]: {
		type: "foo"
		if type == "terraform" {
			backend: {
				type: "s3"
			}
		}
	}
}

issue1759: {
	_ports_map: {}
	if len(_ports_map) > 0 {
		port: _ports_map.a.port
	}
	if true {
		_ports_map: a: {port: "80"}
	}
}

arcAlignment: t1: {
	[string]:  {
		if true { }
	}
	if false {
		c: _
	}
}

-- issue2111.cue --
// All arc types, not just regular fields, should be pushed down.
letPushdown: {
	_c: y: 1

	a: {
		for k, v in _c {
			let x = v
			if x != _|_ {
			}
		}
	}
}

-- issue2113.cue --
// Ensure that an enclosing Value clause of a nested comprehension is evaluated
// before the nested comprehension itself is evaluated.
nestedWithEmbeddingOK: {
	c: [1]
	a: {
		for k, v in c {
			{x: 1}
			if a.x != _|_ {
			}
		}
	}
}

nestedWithDynamicFieldOK: {
	_c: y: 1

	a: {
		for k, v in _c {
			if x != _|_ {
			}
			x="\(k)": 1
		}
	}
}

// Errors in nested comprehensions should also be reported.
errorPropagation: {
	deployment: _
	for k, v in deployment {
		for k1, v2 in v.env2 { // Report this error.
			deployment: (k): x1: 1
		}
	}
	for id in ["elem"] { deployment: (id): x2: 2 }
}

-- issue2131.cue --
issue2131: tests: {
	windows: {
		eg1: in: #"c:\d"#
		eg2: in: #"c:\test"#
		eg3: in: #"c:\test\d"#
	}

	for os, examples in tests for k, v in examples {
		(os): (k): out: "test"
	}
}
-- issue3533.cue --
issue3533: {
	#ObjectMeta: namespace?: string
	out: {
		for i, _ in ["iter-once"] {
			metadata: #ObjectMeta
			if false {
				metadata: namespace: "foo"
			}
		}
	}
	out: metadata: namespace: *"default" | string
}
-- issue3535.cue --
issue3535: hidden: {
	#X: {
		kind: string
		output: {}
	}
	foo: #X & {
		kind: string
		if kind == "foo" {
			_hidden: {}
		}
	}
	foo: kind: "foo"
}
issue3535: regular: {
	#X: {
		kind: string
		output: {}
	}
	foo: #X & {
		kind: string
		if kind == "foo" {
			regular: {}
		}
	}
	foo: kind: "foo"
}
issue3535: def: {
	#X: {
		kind: string
		output: {}
	}
	foo: #X & {
		kind: string
		if kind == "foo" {
			#def: {}
		}
	}
	foo: kind: "foo"
}
-- reflect.cue --
import "encoding/json"


unifyDynamicReflectSuccess: {
	for _, s in ["foo"] {
		X: {...}
		"\(s)": {
			X: {...} // cannot be _
			Y: json.Marshal(X) // cannot be yaml, X cannot be literal
		}
	}

	[string]: X: {
		if true {// must be there
			x: y: {} // at least 2 nestings needed to expose problem
		}
	}
}
-- issue3621.cue --
issue3621: reduced: t1: {
	// This test ensures that when a reference is made within a comprehension,
	// with vertices marked as "pending", that these are not completed the
	// respective pushed-down comprehension is evaluated as well.
	if true {
		a: b1.b2.b3
		b1: b2: b3: "Foo"
	}
}
issue3621: reduced: t2: {
	outer: {}
	if true {
		inner: inner2: name: "Foo"
		outer: b: inner.inner2.name
	}
}
issue3621: full: {
	hello: "world"
	outer: [Name=string]: name: Name
	if true {
		inner: inner2: {
			name:           "Employees"
			description:    "All employees"
			privacy:        "secret"
			create_default: false
		}
		outer: outer2: {
			bar: (inner.inner2.name)
		}
	}
}
-- issue3708.cue --
issue3708: {
	out: people.bob.kind

	// pattern constraint marks 'name' as member, which should not preclude name
	// from being futher evaluated to determine whether 'people' is pending.
	people: [string]: {
		kind:  "person"
		name?: string
	}

	if true {
		people: bob: name: "Bob"
	}
}
-- issue3729.cue --
issue3729: withDisjunction: {
	#Root: sub1?: #sub2?: bool
	root?: null | #Root
	if true {
		root: sub1?: #sub2: true
	}
}
issue3729: withoutDisjunction: {
	root?: null
	if true {
		root: #sub1?: #sub2: true
	}
}
issue3729: withoutDisjunctionWithEmbed: {
	root?: null
	if true {
		root: {_, #sub1?: #sub2: true}
	}
}
issue3729: definitionsOnly: {
	#Root: #sub1?: #sub2?: bool
	root?: null | #Root
	if true {
		root: #sub1?: #sub2: true
	}
}
issue3729: withEmbed: incomplete: {
	#Root: #sub1?: #sub2?: bool
	root?: null | #Root
	if true {
		root: {_, #sub1?: #sub2: true}
	}
}
issue3729: full: {
	#Application: spec: #ApplicationSpec
	#ApplicationSpec: syncPolicy?: null | #SyncPolicy
	#SyncPolicy: automated?: null | #SyncPolicyAutomated
	#SyncPolicyAutomated: {
		prune?:    bool
		selfHeal?: bool
	}
	argoApp: #Application & {
		spec: {
			if true {
				syncPolicy: automated: {
					prune:    true
					selfHeal: true
				}
			}
		}
	}
	argoApp: spec: _syncpolicy: "selfhealprune"
}
-- pending.cue --
// resolving comprehensions arcs across disjunctions.
arcTypeAcrossTwo: {
	a?: b?: {
		c?: null | {}
	} | null
	if true {
		a: b: c: d: true
	}
}
issue3894: reduced: p1: {
	{a: string} | {b: value: string}
	if true { b: value: "true" }
}
issue3894: reduced: p2: {
	{b: value: string} | {a: string}
	if true { b: value: "true" }
}
issue3894: full: {
	#Output: {a?: string} | {b?: {value: string}}
	out: #Output
	out: {
		if true == true {
			b: {value: "true"}
		}
	}
}
-- issue3935.cue --
issue3935: reduced: {
	out: #A | #B
	out: #B & {
		y: x: "bar"
	}
	#A: y: other: int
	#B: {
		if true {
			x: y.x
		}
		y!: x!: _
	}
}
issue3935: full: {
	out: #SchemaOther | #SchemaSelected
	out: #SchemaSelected & {
		spec: {
			name: "foo"
			config: namespace: "bar"
		}
	}
	#SchemaOther: {
		spec: {
			otherOptional?: int
			otherRegular:   int
			otherRequired!: int
		}
	}
	#SchemaSelected: {
		spec!: {
			name!: string
			config!: _
		}

		if true {
			namespace: _specConfig.namespace
		}

		_specConfig: spec.config
	}
}
-- out/evalalpha --
Errors:
embed.fail1.p: field not allowed:
    ./in.cue:46:4
    ./in.cue:49:9
embed.fail4.p: field not allowed:
    ./in.cue:87:4
issue3535.regular.foo.regular: field not allowed:
    ./issue3535.cue:22:4
issue3729.withoutDisjunction.root.#sub1.#sub2: conflicting values null and {#sub1?:{#sub2:true}} (mismatched types null and struct):
    ./issue3729.cue:9:9
    ./issue3729.cue:11:9
noStackOverflowStructCycle.#list.tail: structural cycle
noStackOverflowStructCycle.list.tail: structural cycle
provideIncompleteSuccess.t2.a.c.d: field not allowed:
    ./in.cue:203:8
structShare.err1.x.d.e: field not allowed:
    ./in.cue:591:9
fieldMismatch.a: cannot combine regular field "x" with 2:
    ./in.cue:152:7
    ./in.cue:150:3

Result:
(_|_){
  // [eval]
  linkChildren: (struct){
    w: (int){ 1 }
    v: (struct){
      x: (int){ 1 }
      y: (int){ 1 }
      z: (int){ 1 }
      rw: (int){ 1 }
      rx: (int){ 1 }
      ry: (int){ 1 }
      rz: (int){ 1 }
      n1a: (struct){
        na: (#list){
          0: (int){ 1 }
          1: (int){ 1 }
          2: (int){ 1 }
          3: (int){ 1 }
        }
      }
      n2a: (struct){
        n1a: (struct){
          na: (#list){
            0: (int){ 1 }
            1: (int){ 1 }
            2: (int){ 1 }
            3: (int){ 1 }
          }
        }
      }
      n2z: (struct){
        n1z: (struct){
          nz: (int){ 1 }
        }
      }
    }
  }
  fail: (struct){
    a: (_|_){
      // [incomplete] fail.a.b: cyclic reference to field b:
      //     ./in.cue:30:3
    }
  }
  embed: (_|_){
    // [eval]
    fail1: (_|_){
      // [eval]
      p: (_|_){
        // [eval] embed.fail1.p: field not allowed:
        //     ./in.cue:46:4
        //     ./in.cue:49:9
      }
    }
    #C1: (#struct){
    }
    success2: (#struct){
      p: (string){ "foo" }
    }
    #C2: (#struct){
      p: (_){ _ }
    }
    success3: (#struct){
    }
    #C3: (#struct){
    }
    success4: (struct){
      #X: (#struct){
        y: (string){ string }
      }
      x: (#struct){
        y: (string){ string }
      }
    }
    fail4: (_|_){
      // [eval]
      p: (_|_){
        // [eval] embed.fail4.p: field not allowed:
        //     ./in.cue:87:4
        q: (_|_){
          // [eval] embed.fail4.p.q: field not allowed:
          //     ./in.cue:87:7
        }
      }
    }
    #C4: (#struct){
    }
    incomplete5: (_|_){
      // [incomplete] embed.incomplete5: incomplete bool: bool:
      //     ./in.cue:92:6
      a: (bool){ bool }
    }
    incomplete6: (struct){
      p: (_|_){
        // [incomplete] embed.incomplete6.p: non-concrete value int in operand to +:
        //     ./in.cue:102:6
        //     ./in.cue:103:6
      }
      q: (int){ int }
    }
    incomplete7: (struct){
      p: (_|_){
        // [incomplete] embed.incomplete7.p: non-concrete value int in operand to +:
        //     ./in.cue:106:6
        //     ./in.cue:107:6
        //     ./in.cue:108:3
      }
      q: (int){ int }
    }
  }
  mixedFieldsSuccess: (struct){
    a: (struct){
      X: (int){ 1 }
      foo: (int){ 1 }
    }
    b: (struct){
      #Def: (#struct){
        X: (int){ 1 }
        foo: (int){ 1 }
      }
      x: (#struct){
        X: (int){ 1 }
        foo: (int){ 1 }
      }
    }
    c: (struct){
      #Def: (#struct){
        X: (int){ int }
        foo: (int){ int }
      }
      x: (#struct){
        X: (int){ 1 }
        foo: (int){ 1 }
      }
    }
  }
  fieldMismatch: (_|_){
    // [eval]
    a: (_|_){
      // [eval] fieldMismatch.a: cannot combine regular field "x" with 2:
      //     ./in.cue:152:7
      //     ./in.cue:150:3
      x: (int){ 3 }
    }
  }
  noStackOverflowStructCycle: (_|_){
    // [structural cycle]
    #list: (_|_){
      // [structural cycle] noStackOverflowStructCycle.#list.tail: structural cycle
    }
    list: (_|_){
      // [structural cycle] noStackOverflowStructCycle.list.tail: structural cycle
    }
  }
  provideIncompleteSuccess: (_|_){
    // [eval]
    t1: (struct){
      #a: (_|_){
        // [incomplete] provideIncompleteSuccess.t1.#a: incomplete bool: bool:
        //     ./in.cue:185:7
        b: (bool){ bool }
      }
      x: (#struct){
        b: (bool){ true }
        c: (int){ 4 }
      }
      y: ~(provideIncompleteSuccess.t1.x)
    }
    t2: (_|_){
      // [eval]
      #a: (#struct){
        c: (int){ 4 }
        b: (bool){ true }
      }
      #c: (#struct){
      }
      a: (_|_){
        // [eval]
        c: (_|_){
          // [eval]
          d: (_|_){
            // [eval] provideIncompleteSuccess.t2.a.c.d: field not allowed:
            //     ./in.cue:203:8
          }
        }
        b: (bool){ true }
      }
    }
  }
  voidArcs: (struct){
    scopes: (struct){
      x: (int){ 1 }
      a: (struct){
        y: (int){ 2 }
        b: (int){ 1 }
        c: (struct){
          d: (int){ 1 }
        }
        e: (int){ 2 }
        f: (struct){
          g: (int){ 2 }
        }
      }
    }
    drop: (struct){
      x: (int){ 1 }
      a: (struct){
        y: (int){ 2 }
      }
    }
  }
  cyclicError: (struct){
    a: (_|_){
      // [incomplete] cyclicError.a: incomplete bool: bool:
      //     ./in.cue:245:6
      x: (_|_){
        // [incomplete] cyclicError.a: incomplete bool: bool:
        //     ./in.cue:245:6
      }
      y: (_|_){
        // [incomplete] cyclicError.a: incomplete bool: bool:
        //     ./in.cue:245:6
      }
      b: (struct){
      }
    }
    c: (_|_){
      // [incomplete] cyclicError.a: incomplete bool: bool:
      //     ./in.cue:245:6
    }
  }
  midwayReferences: (struct){
    a: (struct){
      x: (struct){
        y: (struct){
          z: (struct){
            a: (int){ 1 }
            b: (int){ 2 }
          }
        }
      }
    }
    b: ~(midwayReferences.a.x)
    c: ~(midwayReferences.a.x.y)
    d: ~(midwayReferences.a.x.y.z)
  }
  closedCheck: (struct){
    success1: (struct){
      a: (struct){
        b: (struct){
          c: (#struct){
            d: (string){ "d" }
            e: (string){ "ok" }
          }
        }
      }
      #D: (_|_){
        // [incomplete] closedCheck.success1.#D: non-concrete value string in operand to !=:
        //     ./in.cue:280:6
        //     ./in.cue:279:6
        d: (string){ string }
      }
    }
    success2: (struct){
      a: (struct){
        b: (struct){
          c: (#struct){
            d: (string){ "d" }
            foobar: (string){ "ok" }
          }
        }
      }
      #D: (_|_){
        // [incomplete] closedCheck.success2.#D: non-concrete value string in operand to !=:
        //     ./in.cue:296:6
        //     ./in.cue:295:6
        d: (string){ string }
      }
    }
    success3: (struct){
      a: (struct){
        b: (struct){
          c: (#struct){
            d: (string){ "d" }
            e: (string){ "ok" }
          }
        }
      }
      #D: (#struct){
        d: (string){ string }
        e: (_|_){
          // [incomplete] closedCheck.success3.#D.e: non-concrete value string in operand to !=:
          //     ./in.cue:313:7
          //     ./in.cue:311:6
        }
      }
    }
  }
  emptyComprehensionIncomplete: (struct){
    a: (struct){
    }
    b: (_|_){
      // [incomplete] emptyComprehensionIncomplete.b: undefined field: b:
      //     ./in.cue:329:8
    }
  }
  voidEliminationSuccess: (struct){
    t1: (struct){
    }
    t2: (struct){
      components: (struct){
        sinks: (struct){
          blah: (#struct){
            kind: (string){ "source" }
            configuration: (#struct){
            }
          }
        }
        #C: (#struct){
          kind: (string){ string }
          configuration: (#struct){
          }
        }
      }
    }
    derefRef1: (struct){
      a: (struct){
        b: (struct){
          c: (struct){
          }
        }
      }
      E: (struct){
        e: (bool){ bool }
        f: (_|_){
          // [incomplete] voidEliminationSuccess.derefRef1.E.f: operand e of '!' not concrete (was bool):
          //     ./in.cue:386:7
        }
      }
    }
    derefRef2: (struct){
      a: (struct){
        b: (struct){
          c: (struct){
          }
        }
      }
      E: ~(voidEliminationSuccess.derefRef2.#F)
      #F: (#struct){
        e: (bool){ bool }
        f: (_|_){
          // [incomplete] voidEliminationSuccess.derefRef2.#F.f: operand e of '!' not concrete (was bool):
          //     ./in.cue:402:7
        }
      }
    }
    derefDisj1: (struct){
      a: (struct){
        b: (struct){
          c: (struct){
          }
        }
      }
      E: (_|_){
        // [incomplete] voidEliminationSuccess.derefDisj1.E: 2 errors in empty disjunction:
        // voidEliminationSuccess.derefDisj1.E.f: operand e of '!' not concrete (was bool):
        //     ./in.cue:417:7
        // voidEliminationSuccess.derefDisj1.E.h: operand g of '!' not concrete (was bool):
        //     ./in.cue:420:7
      }
    }
    derefDisj2: (struct){
      a: (struct){
        b: (struct){
          c: (struct){
          }
        }
      }
      E: (_|_){
        // [incomplete] voidEliminationSuccess.derefDisj2.E: 2 errors in empty disjunction:
        // voidEliminationSuccess.derefDisj2.E.f: operand e of '!' not concrete (was bool):
        //     ./in.cue:435:7
        // voidEliminationSuccess.derefDisj2.E.h: operand g of '!' not concrete (was bool):
        //     ./in.cue:438:7
      }
    }
    bulk1: (struct){
      a: (struct){
        b: (struct){
          c: (struct){
            e: (string){ string }
          }
          d: (string){ string }
        }
      }
    }
    opt1: (struct){
      a: (struct){
        b: (struct){
          c: (struct){
            e: (string){ string }
          }
          d: (string){ string }
        }
      }
    }
    noCycle1: (struct){
      _x: (struct){
      }
      a: (struct){
        c: (struct){
          h: (string){ "stream" }
        }
        b: (struct){
        }
      }
    }
    noCycle2: (struct){
      a: (struct){
        c: (struct){
          h: (string){ "stream" }
        }
        b: (struct){
        }
      }
      _x: (struct){
      }
    }
    drop1: (struct){
      t: (struct){
        #ok: (bool){ |(*(bool){ true }, (bool){ bool }) }
        x: (int){ int }
      }
      s: (struct){
        #ok: (bool){ false }
      }
    }
  }
  voidLookup: (struct){
    a: (struct){
      x: (struct){
        z: (_|_){
          // [incomplete] voidLookup.a.x.z: undefined field: void:
          //     ./in.cue:495:17
        }
        c: (_|_){
          // [incomplete] voidLookup.a.x.z: undefined field: void:
          //     ./in.cue:495:17
        }
      }
      y: (struct){
        c: (_){ _ }
        z: (struct){
        }
      }
    }
  }
  topElimination: (struct){
    a: (int){ int }
    x: (_|_){
      // [incomplete] topElimination.x: non-concrete value int in operand to +:
      //     ./in.cue:523:6
      //     ./in.cue:520:5
    }
  }
  explicitDefaultError: (_|_){
    // [incomplete] explicitDefaultError: non-concrete value string in operand to !=:
    //     ./in.cue:545:5
    //     ./in.cue:543:5
    a: (string){ string }
  }
  allArcsSuccess: (struct){
    p1: (struct){
      x: (struct){
      }
      y: (struct){
      }
    }
    p2: (struct){
      y: (struct){
      }
      x: (struct){
      }
    }
  }
  structShare: (_|_){
    // [eval]
    ok1: (struct){
      a: (struct){
        d: (struct){
          e: (bool){ true }
        }
      }
      E: (struct){
      }
    }
    err1: (_|_){
      // [eval]
      x: (_|_){
        // [eval]
        #E: (#struct){
        }
        d: (_|_){
          // [eval]
          e: (_|_){
            // [eval] structShare.err1.x.d.e: field not allowed:
            //     ./in.cue:591:9
          }
        }
      }
    }
  }
  unity: (struct){
    success1: (struct){
      #Config: (#struct){
        name: (string){ string }
        type: (string){ string }
      }
      #AnyConfig: (#struct){
        name: (string){ string }
        type: (string){ string }
      }
      #Env: (#struct){
        name: (string){ string }
        configurations: (#struct){
        }
      }
      envs: (struct){
        e1: (#struct){
          configurations: (#struct){
            c1: (#struct){
              type: (string){ "foo" }
              name: (string){ string }
            }
          }
          name: (string){ string }
        }
      }
    }
  }
  issue1759: (struct){
    _ports_map: (struct){
      a: (struct){
        port: (string){ "80" }
      }
    }
    port: (string){ "80" }
  }
  arcAlignment: (struct){
    t1: (struct){
    }
  }
  letPushdown: (struct){
    _c: (struct){
      y: (int){ 1 }
    }
    a: (struct){
      let x#1multi = 〈1;v〉
    }
  }
  nestedWithEmbeddingOK: (struct){
    c: (#list){
      0: (int){ 1 }
    }
    a: (struct){
      x: (int){ 1 }
    }
  }
  nestedWithDynamicFieldOK: (struct){
    _c: (struct){
      y: (int){ 1 }
    }
    a: (struct){
      y: (int){ 1 }
    }
  }
  errorPropagation: (_|_){
    // [incomplete] errorPropagation: undefined field: env2:
    //     ./issue2113.cue:30:19
    deployment: (_|_){
      // [incomplete] errorPropagation: undefined field: env2:
      //     ./issue2113.cue:30:19
      elem: (struct){
        x2: (int){ 2 }
      }
    }
  }
  issue2131: (struct){
    tests: (struct){
      windows: (struct){
        eg1: (struct){
          in: (string){ "c:\\d" }
          out: (string){ "test" }
        }
        eg2: (struct){
          in: (string){ "c:\\test" }
          out: (string){ "test" }
        }
        eg3: (struct){
          in: (string){ "c:\\test\\d" }
          out: (string){ "test" }
        }
      }
    }
  }
  voidErrorIncomplete: (struct){
    #Schema: (#struct){
    }
    root: (#struct){
    }
  }
  issue3533: (struct){
    #ObjectMeta: (#struct){
      namespace?: (string){ string }
    }
    out: (struct){
      metadata: (#struct){
        namespace: (string){ |(*(string){ "default" }, (string){ string }) }
      }
    }
  }
  issue3535: (_|_){
    // [eval]
    hidden: (struct){
      #X: (#struct){
        kind: (string){ string }
        output: (#struct){
        }
      }
      foo: (#struct){
        kind: (string){ "foo" }
        _hidden: (struct){
        }
        output: (#struct){
        }
      }
    }
    regular: (_|_){
      // [eval]
      #X: (#struct){
        kind: (string){ string }
        output: (#struct){
        }
      }
      foo: (_|_){
        // [eval]
        kind: (string){ "foo" }
        regular: (_|_){
          // [eval] issue3535.regular.foo.regular: field not allowed:
          //     ./issue3535.cue:22:4
        }
        output: (#struct){
        }
      }
    }
    def: (struct){
      #X: (#struct){
        kind: (string){ string }
        output: (#struct){
        }
      }
      foo: (#struct){
        kind: (string){ "foo" }
        #def: (#struct){
        }
        output: (#struct){
        }
      }
    }
  }
  issue3621: (struct){
    reduced: (struct){
      t1: (struct){
        a: (string){ "Foo" }
        b1: (struct){
          b2: (struct){
            b3: (string){ "Foo" }
          }
        }
      }
      t2: (struct){
        outer: (struct){
          b: (string){ "Foo" }
        }
        inner: (struct){
          inner2: (struct){
            name: (string){ "Foo" }
          }
        }
      }
    }
    full: (struct){
      hello: (string){ "world" }
      outer: (struct){
        outer2: (struct){
          bar: (string){ "Employees" }
          name: (string){ "outer2" }
        }
      }
      inner: (struct){
        inner2: (struct){
          name: (string){ "Employees" }
          description: (string){ "All employees" }
          privacy: (string){ "secret" }
          create_default: (bool){ false }
        }
      }
    }
  }
  issue3708: (struct){
    out: (string){ "person" }
    people: (struct){
      bob: (struct){
        name: (string){ "Bob" }
        kind: (string){ "person" }
      }
    }
  }
  issue3729: (_|_){
    // [eval]
    withDisjunction: (struct){
      #Root: (#struct){
        sub1?: (#struct){
          #sub2?: (bool){ bool }
        }
      }
      root: (#struct){
        sub1?: (#struct){
          #sub2: (bool){ true }
        }
      }
    }
    withoutDisjunction: (_|_){
      // [eval]
      root: (_|_){
        // [eval] issue3729.withoutDisjunction.root.#sub1.#sub2: conflicting values null and {#sub1?:{#sub2:true}} (mismatched types null and struct):
        //     ./issue3729.cue:9:9
        //     ./issue3729.cue:11:9
        #sub1?: (#struct){
          #sub2: (bool){ true }
        }
      }
    }
    withoutDisjunctionWithEmbed: (struct){
      root: (null){
        null
        #sub1?: (#struct){
          #sub2: (bool){ true }
        }
      }
    }
    definitionsOnly: (struct){
      #Root: (#struct){
        #sub1?: (#struct){
          #sub2?: (bool){ bool }
        }
      }
      root: (#struct){
        #sub1?: (#struct){
          #sub2: (bool){ true }
        }
      }
    }
    withEmbed: (struct){
      incomplete: (struct){
        #Root: (#struct){
          #sub1?: (#struct){
            #sub2?: (bool){ bool }
          }
        }
        root: ((null|struct)){ |((null){
            null
            #sub1?: (#struct){
              #sub2: (bool){ true }
            }
          }, (#struct){
            #sub1?: (#struct){
              #sub2: (bool){ true }
            }
          }) }
      }
    }
    full: (struct){
      #Application: (#struct){
        spec: ~(issue3729.full.#ApplicationSpec)
      }
      #ApplicationSpec: (#struct){
        syncPolicy?: ((null|struct)){ |((null){ null }, (#struct){
            automated?: ((null|struct)){ |((null){ null }, (#struct){
                prune?: (bool){ bool }
                selfHeal?: (bool){ bool }
              }) }
          }) }
      }
      #SyncPolicy: (#struct){
        automated?: ((null|struct)){ |((null){ null }, (#struct){
            prune?: (bool){ bool }
            selfHeal?: (bool){ bool }
          }) }
      }
      #SyncPolicyAutomated: (#struct){
        prune?: (bool){ bool }
        selfHeal?: (bool){ bool }
      }
      argoApp: (#struct){
        spec: (#struct){
          syncPolicy: (#struct){
            automated: (#struct){
              prune: (bool){ true }
              selfHeal: (bool){ true }
            }
          }
          _syncpolicy: (string){ "selfhealprune" }
        }
      }
    }
  }
  issue3935: (struct){
    reduced: (struct){
      out: (#struct){
        y: (#struct){
          x: (string){ "bar" }
        }
        x: (string){ "bar" }
      }
      #A: (#struct){
        y: (#struct){
          other: (int){ int }
        }
      }
      #B: (#struct){
        x: (_){ _ }
        y!: (#struct){
          x!: (_){ _ }
        }
      }
    }
    full: (struct){
      out: (#struct){
        spec: (#struct){
          name: (string){ "foo" }
          config: (#struct){
            namespace: (string){ "bar" }
          }
        }
        namespace: (string){ "bar" }
        _specConfig: ~(issue3935.full.out.spec.config)
      }
      #SchemaOther: (#struct){
        spec: (#struct){
          otherOptional?: (int){ int }
          otherRegular: (int){ int }
          otherRequired!: (int){ int }
        }
      }
      #SchemaSelected: (#struct){
        spec!: (#struct){
          name!: (string){ string }
          config!: (_){ _ }
        }
        namespace: (_|_){
          // [incomplete] issue3935.full.#SchemaSelected.namespace: _specConfig.namespace undefined as _specConfig is incomplete (type _):
          //     ./issue3935.cue:36:15
        }
        _specConfig: (_){ _ }
      }
    }
  }
  arcTypeAcrossTwo: (struct){
    a: (struct){
      b: (struct){
        c: (struct){
          d: (bool){ true }
        }
      }
    }
  }
  issue3894: (struct){
    reduced: (struct){
      p1: (struct){ |((struct){
          b: (struct){
            value: (string){ "true" }
          }
          a: (string){ string }
        }, (struct){
          b: (struct){
            value: (string){ "true" }
          }
        }) }
      p2: (struct){ |((struct){
          b: (struct){
            value: (string){ "true" }
          }
        }, (struct){
          b: (struct){
            value: (string){ "true" }
          }
          a: (string){ string }
        }) }
    }
    full: (struct){
      #Output: (#struct){ |((#struct){
          a?: (string){ string }
        }, (#struct){
          b?: (#struct){
            value: (string){ string }
          }
        }) }
      out: (#struct){
        b: (#struct){
          value: (string){ "true" }
        }
      }
    }
  }
  unifyDynamicReflectSuccess: (struct){
    X: (struct){
      X: (struct){
        x: (struct){
          y: (struct){
          }
        }
      }
    }
    foo: (struct){
      X: (struct){
        x: (struct){
          y: (struct){
          }
        }
      }
      Y: (string){ "{\"x\":{\"y\":{}}}" }
    }
  }
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -1,39 +1,19 @@
 Errors:
 embed.fail1.p: field not allowed:
-    ./in.cue:37:9
-    ./in.cue:38:7
-    ./in.cue:45:3
-    ./in.cue:45:12
     ./in.cue:46:4
     ./in.cue:49:9
 embed.fail4.p: field not allowed:
-    ./in.cue:82:9
-    ./in.cue:83:7
-    ./in.cue:84:9
-    ./in.cue:85:3
     ./in.cue:87:4
 issue3535.regular.foo.regular: field not allowed:
-    ./issue3535.cue:15:6
-    ./issue3535.cue:19:7
-    ./issue3535.cue:19:12
-    ./issue3535.cue:21:3
     ./issue3535.cue:22:4
-    ./issue3535.cue:25:7
 issue3729.withoutDisjunction.root.#sub1.#sub2: conflicting values null and {#sub1?:{#sub2:true}} (mismatched types null and struct):
     ./issue3729.cue:9:9
-    ./issue3729.cue:10:2
     ./issue3729.cue:11:9
 noStackOverflowStructCycle.#list.tail: structural cycle
 noStackOverflowStructCycle.list.tail: structural cycle
 provideIncompleteSuccess.t2.a.c.d: field not allowed:
-    ./in.cue:200:7
-    ./in.cue:202:4
     ./in.cue:203:8
-    ./in.cue:208:7
 structShare.err1.x.d.e: field not allowed:
-    ./in.cue:588:15
-    ./in.cue:589:9
-    ./in.cue:590:2
     ./in.cue:591:9
 fieldMismatch.a: cannot combine regular field "x" with 2:
     ./in.cue:152:7
@@ -79,8 +59,8 @@
   }
   fail: (struct){
     a: (_|_){
-      // [cycle] fail.a: cycle with field a.b:
-      //     ./in.cue:30:6
+      // [incomplete] fail.a.b: cyclic reference to field b:
+      //     ./in.cue:30:3
     }
   }
   embed: (_|_){
@@ -89,10 +69,6 @@
       // [eval]
       p: (_|_){
         // [eval] embed.fail1.p: field not allowed:
-        //     ./in.cue:37:9
-        //     ./in.cue:38:7
-        //     ./in.cue:45:3
-        //     ./in.cue:45:12
         //     ./in.cue:46:4
         //     ./in.cue:49:9
       }
@@ -121,12 +97,11 @@
       // [eval]
       p: (_|_){
         // [eval] embed.fail4.p: field not allowed:
-        //     ./in.cue:82:9
-        //     ./in.cue:83:7
-        //     ./in.cue:84:9
-        //     ./in.cue:85:3
         //     ./in.cue:87:4
-        q: (int){ 1 }
+        q: (_|_){
+          // [eval] embed.fail4.p.q: field not allowed:
+          //     ./in.cue:87:7
+        }
       }
     }
     #C4: (#struct){
@@ -207,13 +182,10 @@
         b: (bool){ bool }
       }
       x: (#struct){
-        c: (int){ 4 }
-        b: (bool){ true }
-      }
-      y: (#struct){
-        c: (int){ 4 }
-        b: (bool){ true }
-      }
+        b: (bool){ true }
+        c: (int){ 4 }
+      }
+      y: ~(provideIncompleteSuccess.t1.x)
     }
     t2: (_|_){
       // [eval]
@@ -229,10 +201,7 @@
           // [eval]
           d: (_|_){
             // [eval] provideIncompleteSuccess.t2.a.c.d: field not allowed:
-            //     ./in.cue:200:7
-            //     ./in.cue:202:4
             //     ./in.cue:203:8
-            //     ./in.cue:208:7
           }
         }
         b: (bool){ true }
@@ -263,9 +232,22 @@
   }
   cyclicError: (struct){
     a: (_|_){
-      // [cycle] cycle error
-    }
-    c: (struct){
+      // [incomplete] cyclicError.a: incomplete bool: bool:
+      //     ./in.cue:245:6
+      x: (_|_){
+        // [incomplete] cyclicError.a: incomplete bool: bool:
+        //     ./in.cue:245:6
+      }
+      y: (_|_){
+        // [incomplete] cyclicError.a: incomplete bool: bool:
+        //     ./in.cue:245:6
+      }
+      b: (struct){
+      }
+    }
+    c: (_|_){
+      // [incomplete] cyclicError.a: incomplete bool: bool:
+      //     ./in.cue:245:6
     }
   }
   midwayReferences: (struct){
@@ -279,24 +261,9 @@
         }
       }
     }
-    b: (struct){
-      y: (struct){
-        z: (struct){
-          a: (int){ 1 }
-          b: (int){ 2 }
-        }
-      }
-    }
-    c: (struct){
-      z: (struct){
-        a: (int){ 1 }
-        b: (int){ 2 }
-      }
-    }
-    d: (struct){
-      a: (int){ 1 }
-      b: (int){ 2 }
-    }
+    b: ~(midwayReferences.a.x)
+    c: ~(midwayReferences.a.x.y)
+    d: ~(midwayReferences.a.x.y.z)
   }
   closedCheck: (struct){
     success1: (struct){
@@ -399,13 +366,7 @@
           }
         }
       }
-      E: (#struct){
-        e: (bool){ bool }
-        f: (_|_){
-          // [incomplete] voidEliminationSuccess.derefRef2.E.f: operand e of '!' not concrete (was bool):
-          //     ./in.cue:402:7
-        }
-      }
+      E: ~(voidEliminationSuccess.derefRef2.#F)
       #F: (#struct){
         e: (bool){ bool }
         f: (_|_){
@@ -422,17 +383,11 @@
         }
       }
       E: (_|_){
-        // [incomplete] voidEliminationSuccess.derefDisj1.E: 2 errors in empty disjunction::
-        //     ./in.cue:407:28
+        // [incomplete] voidEliminationSuccess.derefDisj1.E: 2 errors in empty disjunction:
         // voidEliminationSuccess.derefDisj1.E.f: operand e of '!' not concrete (was bool):
         //     ./in.cue:417:7
         // voidEliminationSuccess.derefDisj1.E.h: operand g of '!' not concrete (was bool):
         //     ./in.cue:420:7
-        g: (bool){ bool }
-        h: (_|_){
-          // [incomplete] voidEliminationSuccess.derefDisj1.E.h: operand g of '!' not concrete (was bool):
-          //     ./in.cue:420:7
-        }
       }
     }
     derefDisj2: (struct){
@@ -443,17 +398,11 @@
         }
       }
       E: (_|_){
-        // [incomplete] voidEliminationSuccess.derefDisj2.E: 2 errors in empty disjunction::
-        //     ./in.cue:425:28
+        // [incomplete] voidEliminationSuccess.derefDisj2.E: 2 errors in empty disjunction:
         // voidEliminationSuccess.derefDisj2.E.f: operand e of '!' not concrete (was bool):
         //     ./in.cue:435:7
         // voidEliminationSuccess.derefDisj2.E.h: operand g of '!' not concrete (was bool):
         //     ./in.cue:438:7
-        g: (bool){ bool }
-        h: (_|_){
-          // [incomplete] voidEliminationSuccess.derefDisj2.E.h: operand g of '!' not concrete (was bool):
-          //     ./in.cue:438:7
-        }
       }
     }
     bulk1: (struct){
@@ -576,9 +525,6 @@
           // [eval]
           e: (_|_){
             // [eval] structShare.err1.x.d.e: field not allowed:
-            //     ./in.cue:588:15
-            //     ./in.cue:589:9
-            //     ./in.cue:590:2
             //     ./in.cue:591:9
           }
         }
@@ -602,13 +548,13 @@
       }
       envs: (struct){
         e1: (#struct){
-          name: (string){ string }
           configurations: (#struct){
             c1: (#struct){
-              name: (string){ string }
               type: (string){ "foo" }
-            }
-          }
+              name: (string){ string }
+            }
+          }
+          name: (string){ string }
         }
       }
     }
@@ -645,9 +591,8 @@
     _c: (struct){
       y: (int){ 1 }
     }
-    a: (_|_){
-      // [cycle] nestedWithDynamicFieldOK.a: circular dependency in evaluation of conditionals: "\(〈1;k〉)" changed after evaluation:
-      //     ./issue2113.cue:19:7
+    a: (struct){
+      y: (int){ 1 }
     }
   }
   errorPropagation: (_|_){
@@ -705,10 +650,10 @@
       }
       foo: (#struct){
         kind: (string){ "foo" }
-        output: (#struct){
-        }
         _hidden: (struct){
         }
+        output: (#struct){
+        }
       }
     }
     regular: (_|_){
@@ -721,16 +666,11 @@
       foo: (_|_){
         // [eval]
         kind: (string){ "foo" }
-        output: (#struct){
-        }
         regular: (_|_){
           // [eval] issue3535.regular.foo.regular: field not allowed:
-          //     ./issue3535.cue:15:6
-          //     ./issue3535.cue:19:7
-          //     ./issue3535.cue:19:12
-          //     ./issue3535.cue:21:3
           //     ./issue3535.cue:22:4
-          //     ./issue3535.cue:25:7
+        }
+        output: (#struct){
         }
       }
     }
@@ -742,10 +682,10 @@
       }
       foo: (#struct){
         kind: (string){ "foo" }
-        output: (#struct){
-        }
         #def: (#struct){
         }
+        output: (#struct){
+        }
       }
     }
   }
@@ -816,7 +756,6 @@
       root: (_|_){
         // [eval] issue3729.withoutDisjunction.root.#sub1.#sub2: conflicting values null and {#sub1?:{#sub2:true}} (mismatched types null and struct):
         //     ./issue3729.cue:9:9
-        //     ./issue3729.cue:10:2
         //     ./issue3729.cue:11:9
         #sub1?: (#struct){
           #sub2: (bool){ true }
@@ -864,14 +803,7 @@
     }
     full: (struct){
       #Application: (#struct){
-        spec: (#struct){
-          syncPolicy?: ((null|struct)){ |((null){ null }, (#struct){
-              automated?: ((null|struct)){ |((null){ null }, (#struct){
-                  prune?: (bool){ bool }
-                  selfHeal?: (bool){ bool }
-                }) }
-            }) }
-        }
+        spec: ~(issue3729.full.#ApplicationSpec)
       }
       #ApplicationSpec: (#struct){
         syncPolicy?: ((null|struct)){ |((null){ null }, (#struct){
@@ -907,10 +839,10 @@
   issue3935: (struct){
     reduced: (struct){
       out: (#struct){
-        x: (string){ "bar" }
         y: (#struct){
           x: (string){ "bar" }
         }
+        x: (string){ "bar" }
       }
       #A: (#struct){
         y: (#struct){
@@ -928,14 +860,12 @@
       out: (#struct){
         spec: (#struct){
           name: (string){ "foo" }
-          config: (struct){
+          config: (#struct){
             namespace: (string){ "bar" }
           }
         }
         namespace: (string){ "bar" }
-        _specConfig: (#struct){
-          namespace: (string){ "bar" }
-        }
+        _specConfig: ~(issue3935.full.out.spec.config)
       }
       #SchemaOther: (#struct){
         spec: (#struct){
@@ -950,7 +880,7 @@
           config!: (_){ _ }
         }
         namespace: (_|_){
-          // [incomplete] issue3935.full.#SchemaSelected.namespace: _specConfig.namespace undefined (_specConfig is incomplete):
+          // [incomplete] issue3935.full.#SchemaSelected.namespace: _specConfig.namespace undefined as _specConfig is incomplete (type _):
           //     ./issue3935.cue:36:15
         }
         _specConfig: (_){ _ }
-- out/evalalpha/stats --
Leaks:  748
Freed:  0
Reused: 0
Allocs: 748
Retain: 0

Unifications: 638
Conjuncts:    1093
Disjuncts:    48

CloseIDElems: 301
NumCloseIDs: 190
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
diff old new
--- old
+++ new
@@ -1,9 +1,12 @@
-Leaks:  74
-Freed:  602
-Reused: 597
-Allocs: 79
-Retain: 132
-
-Unifications: 624
-Conjuncts:    1004
-Disjuncts:    756
+Leaks:  748
+Freed:  0
+Reused: 0
+Allocs: 748
+Retain: 0
+
+Unifications: 638
+Conjuncts:    1093
+Disjuncts:    48
+
+CloseIDElems: 301
+NumCloseIDs: 190
-- out/eval/stats --
Leaks:  74
Freed:  602
Reused: 597
Allocs: 79
Retain: 132

Unifications: 624
Conjuncts:    1004
Disjuncts:    756
-- diff/explanation --
cyclicError: improved error message.
nestedWithDynamicFieldOK: fixed bug.
-- out/eval --
Errors:
embed.fail1.p: field not allowed:
    ./in.cue:37:9
    ./in.cue:38:7
    ./in.cue:45:3
    ./in.cue:45:12
    ./in.cue:46:4
    ./in.cue:49:9
embed.fail4.p: field not allowed:
    ./in.cue:82:9
    ./in.cue:83:7
    ./in.cue:84:9
    ./in.cue:85:3
    ./in.cue:87:4
issue3535.regular.foo.regular: field not allowed:
    ./issue3535.cue:15:6
    ./issue3535.cue:19:7
    ./issue3535.cue:19:12
    ./issue3535.cue:21:3
    ./issue3535.cue:22:4
    ./issue3535.cue:25:7
issue3729.withoutDisjunction.root.#sub1.#sub2: conflicting values null and {#sub1?:{#sub2:true}} (mismatched types null and struct):
    ./issue3729.cue:9:9
    ./issue3729.cue:10:2
    ./issue3729.cue:11:9
noStackOverflowStructCycle.#list.tail: structural cycle
noStackOverflowStructCycle.list.tail: structural cycle
provideIncompleteSuccess.t2.a.c.d: field not allowed:
    ./in.cue:200:7
    ./in.cue:202:4
    ./in.cue:203:8
    ./in.cue:208:7
structShare.err1.x.d.e: field not allowed:
    ./in.cue:588:15
    ./in.cue:589:9
    ./in.cue:590:2
    ./in.cue:591:9
fieldMismatch.a: cannot combine regular field "x" with 2:
    ./in.cue:152:7
    ./in.cue:150:3

Result:
(_|_){
  // [eval]
  linkChildren: (struct){
    w: (int){ 1 }
    v: (struct){
      x: (int){ 1 }
      y: (int){ 1 }
      z: (int){ 1 }
      rw: (int){ 1 }
      rx: (int){ 1 }
      ry: (int){ 1 }
      rz: (int){ 1 }
      n1a: (struct){
        na: (#list){
          0: (int){ 1 }
          1: (int){ 1 }
          2: (int){ 1 }
          3: (int){ 1 }
        }
      }
      n2a: (struct){
        n1a: (struct){
          na: (#list){
            0: (int){ 1 }
            1: (int){ 1 }
            2: (int){ 1 }
            3: (int){ 1 }
          }
        }
      }
      n2z: (struct){
        n1z: (struct){
          nz: (int){ 1 }
        }
      }
    }
  }
  fail: (struct){
    a: (_|_){
      // [cycle] fail.a: cycle with field a.b:
      //     ./in.cue:30:6
    }
  }
  embed: (_|_){
    // [eval]
    fail1: (_|_){
      // [eval]
      p: (_|_){
        // [eval] embed.fail1.p: field not allowed:
        //     ./in.cue:37:9
        //     ./in.cue:38:7
        //     ./in.cue:45:3
        //     ./in.cue:45:12
        //     ./in.cue:46:4
        //     ./in.cue:49:9
      }
    }
    #C1: (#struct){
    }
    success2: (#struct){
      p: (string){ "foo" }
    }
    #C2: (#struct){
      p: (_){ _ }
    }
    success3: (#struct){
    }
    #C3: (#struct){
    }
    success4: (struct){
      #X: (#struct){
        y: (string){ string }
      }
      x: (#struct){
        y: (string){ string }
      }
    }
    fail4: (_|_){
      // [eval]
      p: (_|_){
        // [eval] embed.fail4.p: field not allowed:
        //     ./in.cue:82:9
        //     ./in.cue:83:7
        //     ./in.cue:84:9
        //     ./in.cue:85:3
        //     ./in.cue:87:4
        q: (int){ 1 }
      }
    }
    #C4: (#struct){
    }
    incomplete5: (_|_){
      // [incomplete] embed.incomplete5: incomplete bool: bool:
      //     ./in.cue:92:6
      a: (bool){ bool }
    }
    incomplete6: (struct){
      p: (_|_){
        // [incomplete] embed.incomplete6.p: non-concrete value int in operand to +:
        //     ./in.cue:102:6
        //     ./in.cue:103:6
      }
      q: (int){ int }
    }
    incomplete7: (struct){
      p: (_|_){
        // [incomplete] embed.incomplete7.p: non-concrete value int in operand to +:
        //     ./in.cue:106:6
        //     ./in.cue:107:6
        //     ./in.cue:108:3
      }
      q: (int){ int }
    }
  }
  mixedFieldsSuccess: (struct){
    a: (struct){
      X: (int){ 1 }
      foo: (int){ 1 }
    }
    b: (struct){
      #Def: (#struct){
        X: (int){ 1 }
        foo: (int){ 1 }
      }
      x: (#struct){
        X: (int){ 1 }
        foo: (int){ 1 }
      }
    }
    c: (struct){
      #Def: (#struct){
        X: (int){ int }
        foo: (int){ int }
      }
      x: (#struct){
        X: (int){ 1 }
        foo: (int){ 1 }
      }
    }
  }
  fieldMismatch: (_|_){
    // [eval]
    a: (_|_){
      // [eval] fieldMismatch.a: cannot combine regular field "x" with 2:
      //     ./in.cue:152:7
      //     ./in.cue:150:3
      x: (int){ 3 }
    }
  }
  noStackOverflowStructCycle: (_|_){
    // [structural cycle]
    #list: (_|_){
      // [structural cycle] noStackOverflowStructCycle.#list.tail: structural cycle
    }
    list: (_|_){
      // [structural cycle] noStackOverflowStructCycle.list.tail: structural cycle
    }
  }
  provideIncompleteSuccess: (_|_){
    // [eval]
    t1: (struct){
      #a: (_|_){
        // [incomplete] provideIncompleteSuccess.t1.#a: incomplete bool: bool:
        //     ./in.cue:185:7
        b: (bool){ bool }
      }
      x: (#struct){
        c: (int){ 4 }
        b: (bool){ true }
      }
      y: (#struct){
        c: (int){ 4 }
        b: (bool){ true }
      }
    }
    t2: (_|_){
      // [eval]
      #a: (#struct){
        c: (int){ 4 }
        b: (bool){ true }
      }
      #c: (#struct){
      }
      a: (_|_){
        // [eval]
        c: (_|_){
          // [eval]
          d: (_|_){
            // [eval] provideIncompleteSuccess.t2.a.c.d: field not allowed:
            //     ./in.cue:200:7
            //     ./in.cue:202:4
            //     ./in.cue:203:8
            //     ./in.cue:208:7
          }
        }
        b: (bool){ true }
      }
    }
  }
  voidArcs: (struct){
    scopes: (struct){
      x: (int){ 1 }
      a: (struct){
        y: (int){ 2 }
        b: (int){ 1 }
        c: (struct){
          d: (int){ 1 }
        }
        e: (int){ 2 }
        f: (struct){
          g: (int){ 2 }
        }
      }
    }
    drop: (struct){
      x: (int){ 1 }
      a: (struct){
        y: (int){ 2 }
      }
    }
  }
  cyclicError: (struct){
    a: (_|_){
      // [cycle] cycle error
    }
    c: (struct){
    }
  }
  midwayReferences: (struct){
    a: (struct){
      x: (struct){
        y: (struct){
          z: (struct){
            a: (int){ 1 }
            b: (int){ 2 }
          }
        }
      }
    }
    b: (struct){
      y: (struct){
        z: (struct){
          a: (int){ 1 }
          b: (int){ 2 }
        }
      }
    }
    c: (struct){
      z: (struct){
        a: (int){ 1 }
        b: (int){ 2 }
      }
    }
    d: (struct){
      a: (int){ 1 }
      b: (int){ 2 }
    }
  }
  closedCheck: (struct){
    success1: (struct){
      a: (struct){
        b: (struct){
          c: (#struct){
            d: (string){ "d" }
            e: (string){ "ok" }
          }
        }
      }
      #D: (_|_){
        // [incomplete] closedCheck.success1.#D: non-concrete value string in operand to !=:
        //     ./in.cue:280:6
        //     ./in.cue:279:6
        d: (string){ string }
      }
    }
    success2: (struct){
      a: (struct){
        b: (struct){
          c: (#struct){
            d: (string){ "d" }
            foobar: (string){ "ok" }
          }
        }
      }
      #D: (_|_){
        // [incomplete] closedCheck.success2.#D: non-concrete value string in operand to !=:
        //     ./in.cue:296:6
        //     ./in.cue:295:6
        d: (string){ string }
      }
    }
    success3: (struct){
      a: (struct){
        b: (struct){
          c: (#struct){
            d: (string){ "d" }
            e: (string){ "ok" }
          }
        }
      }
      #D: (#struct){
        d: (string){ string }
        e: (_|_){
          // [incomplete] closedCheck.success3.#D.e: non-concrete value string in operand to !=:
          //     ./in.cue:313:7
          //     ./in.cue:311:6
        }
      }
    }
  }
  emptyComprehensionIncomplete: (struct){
    a: (struct){
    }
    b: (_|_){
      // [incomplete] emptyComprehensionIncomplete.b: undefined field: b:
      //     ./in.cue:329:8
    }
  }
  voidEliminationSuccess: (struct){
    t1: (struct){
    }
    t2: (struct){
      components: (struct){
        sinks: (struct){
          blah: (#struct){
            kind: (string){ "source" }
            configuration: (#struct){
            }
          }
        }
        #C: (#struct){
          kind: (string){ string }
          configuration: (#struct){
          }
        }
      }
    }
    derefRef1: (struct){
      a: (struct){
        b: (struct){
          c: (struct){
          }
        }
      }
      E: (struct){
        e: (bool){ bool }
        f: (_|_){
          // [incomplete] voidEliminationSuccess.derefRef1.E.f: operand e of '!' not concrete (was bool):
          //     ./in.cue:386:7
        }
      }
    }
    derefRef2: (struct){
      a: (struct){
        b: (struct){
          c: (struct){
          }
        }
      }
      E: (#struct){
        e: (bool){ bool }
        f: (_|_){
          // [incomplete] voidEliminationSuccess.derefRef2.E.f: operand e of '!' not concrete (was bool):
          //     ./in.cue:402:7
        }
      }
      #F: (#struct){
        e: (bool){ bool }
        f: (_|_){
          // [incomplete] voidEliminationSuccess.derefRef2.#F.f: operand e of '!' not concrete (was bool):
          //     ./in.cue:402:7
        }
      }
    }
    derefDisj1: (struct){
      a: (struct){
        b: (struct){
          c: (struct){
          }
        }
      }
      E: (_|_){
        // [incomplete] voidEliminationSuccess.derefDisj1.E: 2 errors in empty disjunction::
        //     ./in.cue:407:28
        // voidEliminationSuccess.derefDisj1.E.f: operand e of '!' not concrete (was bool):
        //     ./in.cue:417:7
        // voidEliminationSuccess.derefDisj1.E.h: operand g of '!' not concrete (was bool):
        //     ./in.cue:420:7
        g: (bool){ bool }
        h: (_|_){
          // [incomplete] voidEliminationSuccess.derefDisj1.E.h: operand g of '!' not concrete (was bool):
          //     ./in.cue:420:7
        }
      }
    }
    derefDisj2: (struct){
      a: (struct){
        b: (struct){
          c: (struct){
          }
        }
      }
      E: (_|_){
        // [incomplete] voidEliminationSuccess.derefDisj2.E: 2 errors in empty disjunction::
        //     ./in.cue:425:28
        // voidEliminationSuccess.derefDisj2.E.f: operand e of '!' not concrete (was bool):
        //     ./in.cue:435:7
        // voidEliminationSuccess.derefDisj2.E.h: operand g of '!' not concrete (was bool):
        //     ./in.cue:438:7
        g: (bool){ bool }
        h: (_|_){
          // [incomplete] voidEliminationSuccess.derefDisj2.E.h: operand g of '!' not concrete (was bool):
          //     ./in.cue:438:7
        }
      }
    }
    bulk1: (struct){
      a: (struct){
        b: (struct){
          c: (struct){
            e: (string){ string }
          }
          d: (string){ string }
        }
      }
    }
    opt1: (struct){
      a: (struct){
        b: (struct){
          c: (struct){
            e: (string){ string }
          }
          d: (string){ string }
        }
      }
    }
    noCycle1: (struct){
      _x: (struct){
      }
      a: (struct){
        c: (struct){
          h: (string){ "stream" }
        }
        b: (struct){
        }
      }
    }
    noCycle2: (struct){
      a: (struct){
        c: (struct){
          h: (string){ "stream" }
        }
        b: (struct){
        }
      }
      _x: (struct){
      }
    }
    drop1: (struct){
      t: (struct){
        #ok: (bool){ |(*(bool){ true }, (bool){ bool }) }
        x: (int){ int }
      }
      s: (struct){
        #ok: (bool){ false }
      }
    }
  }
  voidLookup: (struct){
    a: (struct){
      x: (struct){
        z: (_|_){
          // [incomplete] voidLookup.a.x.z: undefined field: void:
          //     ./in.cue:495:17
        }
        c: (_|_){
          // [incomplete] voidLookup.a.x.z: undefined field: void:
          //     ./in.cue:495:17
        }
      }
      y: (struct){
        c: (_){ _ }
        z: (struct){
        }
      }
    }
  }
  topElimination: (struct){
    a: (int){ int }
    x: (_|_){
      // [incomplete] topElimination.x: non-concrete value int in operand to +:
      //     ./in.cue:523:6
      //     ./in.cue:520:5
    }
  }
  explicitDefaultError: (_|_){
    // [incomplete] explicitDefaultError: non-concrete value string in operand to !=:
    //     ./in.cue:545:5
    //     ./in.cue:543:5
    a: (string){ string }
  }
  allArcsSuccess: (struct){
    p1: (struct){
      x: (struct){
      }
      y: (struct){
      }
    }
    p2: (struct){
      y: (struct){
      }
      x: (struct){
      }
    }
  }
  structShare: (_|_){
    // [eval]
    ok1: (struct){
      a: (struct){
        d: (struct){
          e: (bool){ true }
        }
      }
      E: (struct){
      }
    }
    err1: (_|_){
      // [eval]
      x: (_|_){
        // [eval]
        #E: (#struct){
        }
        d: (_|_){
          // [eval]
          e: (_|_){
            // [eval] structShare.err1.x.d.e: field not allowed:
            //     ./in.cue:588:15
            //     ./in.cue:589:9
            //     ./in.cue:590:2
            //     ./in.cue:591:9
          }
        }
      }
    }
  }
  unity: (struct){
    success1: (struct){
      #Config: (#struct){
        name: (string){ string }
        type: (string){ string }
      }
      #AnyConfig: (#struct){
        name: (string){ string }
        type: (string){ string }
      }
      #Env: (#struct){
        name: (string){ string }
        configurations: (#struct){
        }
      }
      envs: (struct){
        e1: (#struct){
          name: (string){ string }
          configurations: (#struct){
            c1: (#struct){
              name: (string){ string }
              type: (string){ "foo" }
            }
          }
        }
      }
    }
  }
  issue1759: (struct){
    _ports_map: (struct){
      a: (struct){
        port: (string){ "80" }
      }
    }
    port: (string){ "80" }
  }
  arcAlignment: (struct){
    t1: (struct){
    }
  }
  letPushdown: (struct){
    _c: (struct){
      y: (int){ 1 }
    }
    a: (struct){
      let x#1multi = 〈1;v〉
    }
  }
  nestedWithEmbeddingOK: (struct){
    c: (#list){
      0: (int){ 1 }
    }
    a: (struct){
      x: (int){ 1 }
    }
  }
  nestedWithDynamicFieldOK: (struct){
    _c: (struct){
      y: (int){ 1 }
    }
    a: (_|_){
      // [cycle] nestedWithDynamicFieldOK.a: circular dependency in evaluation of conditionals: "\(〈1;k〉)" changed after evaluation:
      //     ./issue2113.cue:19:7
    }
  }
  errorPropagation: (_|_){
    // [incomplete] errorPropagation: undefined field: env2:
    //     ./issue2113.cue:30:19
    deployment: (_|_){
      // [incomplete] errorPropagation: undefined field: env2:
      //     ./issue2113.cue:30:19
      elem: (struct){
        x2: (int){ 2 }
      }
    }
  }
  issue2131: (struct){
    tests: (struct){
      windows: (struct){
        eg1: (struct){
          in: (string){ "c:\\d" }
          out: (string){ "test" }
        }
        eg2: (struct){
          in: (string){ "c:\\test" }
          out: (string){ "test" }
        }
        eg3: (struct){
          in: (string){ "c:\\test\\d" }
          out: (string){ "test" }
        }
      }
    }
  }
  voidErrorIncomplete: (struct){
    #Schema: (#struct){
    }
    root: (#struct){
    }
  }
  issue3533: (struct){
    #ObjectMeta: (#struct){
      namespace?: (string){ string }
    }
    out: (struct){
      metadata: (#struct){
        namespace: (string){ |(*(string){ "default" }, (string){ string }) }
      }
    }
  }
  issue3535: (_|_){
    // [eval]
    hidden: (struct){
      #X: (#struct){
        kind: (string){ string }
        output: (#struct){
        }
      }
      foo: (#struct){
        kind: (string){ "foo" }
        output: (#struct){
        }
        _hidden: (struct){
        }
      }
    }
    regular: (_|_){
      // [eval]
      #X: (#struct){
        kind: (string){ string }
        output: (#struct){
        }
      }
      foo: (_|_){
        // [eval]
        kind: (string){ "foo" }
        output: (#struct){
        }
        regular: (_|_){
          // [eval] issue3535.regular.foo.regular: field not allowed:
          //     ./issue3535.cue:15:6
          //     ./issue3535.cue:19:7
          //     ./issue3535.cue:19:12
          //     ./issue3535.cue:21:3
          //     ./issue3535.cue:22:4
          //     ./issue3535.cue:25:7
        }
      }
    }
    def: (struct){
      #X: (#struct){
        kind: (string){ string }
        output: (#struct){
        }
      }
      foo: (#struct){
        kind: (string){ "foo" }
        output: (#struct){
        }
        #def: (#struct){
        }
      }
    }
  }
  issue3621: (struct){
    reduced: (struct){
      t1: (struct){
        a: (string){ "Foo" }
        b1: (struct){
          b2: (struct){
            b3: (string){ "Foo" }
          }
        }
      }
      t2: (struct){
        outer: (struct){
          b: (string){ "Foo" }
        }
        inner: (struct){
          inner2: (struct){
            name: (string){ "Foo" }
          }
        }
      }
    }
    full: (struct){
      hello: (string){ "world" }
      outer: (struct){
        outer2: (struct){
          bar: (string){ "Employees" }
          name: (string){ "outer2" }
        }
      }
      inner: (struct){
        inner2: (struct){
          name: (string){ "Employees" }
          description: (string){ "All employees" }
          privacy: (string){ "secret" }
          create_default: (bool){ false }
        }
      }
    }
  }
  issue3708: (struct){
    out: (string){ "person" }
    people: (struct){
      bob: (struct){
        name: (string){ "Bob" }
        kind: (string){ "person" }
      }
    }
  }
  issue3729: (_|_){
    // [eval]
    withDisjunction: (struct){
      #Root: (#struct){
        sub1?: (#struct){
          #sub2?: (bool){ bool }
        }
      }
      root: (#struct){
        sub1?: (#struct){
          #sub2: (bool){ true }
        }
      }
    }
    withoutDisjunction: (_|_){
      // [eval]
      root: (_|_){
        // [eval] issue3729.withoutDisjunction.root.#sub1.#sub2: conflicting values null and {#sub1?:{#sub2:true}} (mismatched types null and struct):
        //     ./issue3729.cue:9:9
        //     ./issue3729.cue:10:2
        //     ./issue3729.cue:11:9
        #sub1?: (#struct){
          #sub2: (bool){ true }
        }
      }
    }
    withoutDisjunctionWithEmbed: (struct){
      root: (null){
        null
        #sub1?: (#struct){
          #sub2: (bool){ true }
        }
      }
    }
    definitionsOnly: (struct){
      #Root: (#struct){
        #sub1?: (#struct){
          #sub2?: (bool){ bool }
        }
      }
      root: (#struct){
        #sub1?: (#struct){
          #sub2: (bool){ true }
        }
      }
    }
    withEmbed: (struct){
      incomplete: (struct){
        #Root: (#struct){
          #sub1?: (#struct){
            #sub2?: (bool){ bool }
          }
        }
        root: ((null|struct)){ |((null){
            null
            #sub1?: (#struct){
              #sub2: (bool){ true }
            }
          }, (#struct){
            #sub1?: (#struct){
              #sub2: (bool){ true }
            }
          }) }
      }
    }
    full: (struct){
      #Application: (#struct){
        spec: (#struct){
          syncPolicy?: ((null|struct)){ |((null){ null }, (#struct){
              automated?: ((null|struct)){ |((null){ null }, (#struct){
                  prune?: (bool){ bool }
                  selfHeal?: (bool){ bool }
                }) }
            }) }
        }
      }
      #ApplicationSpec: (#struct){
        syncPolicy?: ((null|struct)){ |((null){ null }, (#struct){
            automated?: ((null|struct)){ |((null){ null }, (#struct){
                prune?: (bool){ bool }
                selfHeal?: (bool){ bool }
              }) }
          }) }
      }
      #SyncPolicy: (#struct){
        automated?: ((null|struct)){ |((null){ null }, (#struct){
            prune?: (bool){ bool }
            selfHeal?: (bool){ bool }
          }) }
      }
      #SyncPolicyAutomated: (#struct){
        prune?: (bool){ bool }
        selfHeal?: (bool){ bool }
      }
      argoApp: (#struct){
        spec: (#struct){
          syncPolicy: (#struct){
            automated: (#struct){
              prune: (bool){ true }
              selfHeal: (bool){ true }
            }
          }
          _syncpolicy: (string){ "selfhealprune" }
        }
      }
    }
  }
  issue3935: (struct){
    reduced: (struct){
      out: (#struct){
        x: (string){ "bar" }
        y: (#struct){
          x: (string){ "bar" }
        }
      }
      #A: (#struct){
        y: (#struct){
          other: (int){ int }
        }
      }
      #B: (#struct){
        x: (_){ _ }
        y!: (#struct){
          x!: (_){ _ }
        }
      }
    }
    full: (struct){
      out: (#struct){
        spec: (#struct){
          name: (string){ "foo" }
          config: (struct){
            namespace: (string){ "bar" }
          }
        }
        namespace: (string){ "bar" }
        _specConfig: (#struct){
          namespace: (string){ "bar" }
        }
      }
      #SchemaOther: (#struct){
        spec: (#struct){
          otherOptional?: (int){ int }
          otherRegular: (int){ int }
          otherRequired!: (int){ int }
        }
      }
      #SchemaSelected: (#struct){
        spec!: (#struct){
          name!: (string){ string }
          config!: (_){ _ }
        }
        namespace: (_|_){
          // [incomplete] issue3935.full.#SchemaSelected.namespace: _specConfig.namespace undefined (_specConfig is incomplete):
          //     ./issue3935.cue:36:15
        }
        _specConfig: (_){ _ }
      }
    }
  }
  arcTypeAcrossTwo: (struct){
    a: (struct){
      b: (struct){
        c: (struct){
          d: (bool){ true }
        }
      }
    }
  }
  issue3894: (struct){
    reduced: (struct){
      p1: (struct){ |((struct){
          b: (struct){
            value: (string){ "true" }
          }
          a: (string){ string }
        }, (struct){
          b: (struct){
            value: (string){ "true" }
          }
        }) }
      p2: (struct){ |((struct){
          b: (struct){
            value: (string){ "true" }
          }
        }, (struct){
          b: (struct){
            value: (string){ "true" }
          }
          a: (string){ string }
        }) }
    }
    full: (struct){
      #Output: (#struct){ |((#struct){
          a?: (string){ string }
        }, (#struct){
          b?: (#struct){
            value: (string){ string }
          }
        }) }
      out: (#struct){
        b: (#struct){
          value: (string){ "true" }
        }
      }
    }
  }
  unifyDynamicReflectSuccess: (struct){
    X: (struct){
      X: (struct){
        x: (struct){
          y: (struct){
          }
        }
      }
    }
    foo: (struct){
      X: (struct){
        x: (struct){
          y: (struct){
          }
        }
      }
      Y: (string){ "{\"x\":{\"y\":{}}}" }
    }
  }
}
-- out/compile --
--- in.cue
{
  linkChildren: {
    w: 1
    v: {
      x: 1
      if true {
        y: 1
        if true {
          z: 1
          rw: 〈3;w〉
          rx: 〈2;x〉
          ry: 〈1;y〉
          rz: 〈0;z〉
          n1a: {
            na: [
              〈5;w〉,
              〈4;x〉,
              〈3;y〉,
              〈2;z〉,
            ]
          }
          n2a: {
            n1a: {
              na: [
                〈6;w〉,
                〈5;x〉,
                〈4;y〉,
                〈3;z〉,
              ]
            }
          }
          n2z: {
            n1z: {
              nz: 〈2;z〉
            }
          }
        }
      }
    }
  }
  fail: {
    a: {
      if (〈1;a〉.b == _|_(explicit error (_|_ literal) in source)) {
        b: 1
      }
    }
  }
  embed: {
    fail1: 〈0;#C1〉
    #C1: {
      if false {
        p: _
      }
    }
    fail1: {
      p: "foo"
    }
    success2: 〈0;#C2〉
    #C2: {
      if true {
        p: _
      }
    }
    success2: {
      p: "foo"
    }
    success3: 〈0;#C3〉
    #C3: {}
    success3: {
      if false {
        p: {
          q: 1
        }
      }
    }
    success4: {
      #X: {
        y: string
      }
      x: {
        y: string
      }
      x: {
        for _, _ in [
          "iter-once",
        ] {
          〈3;#X〉
          if false {
            y: "foo"
          }
        }
      }
    }
    fail4: 〈0;#C4〉
    #C4: {}
    fail4: {
      if true {
        p: {
          q: 1
        }
      }
    }
    incomplete5: {
      a: bool
      if 〈0;a〉 {
        p: {
          q: 1
        }
      }
    }
    incomplete6: {
      if false {
        p: 1
      }
      p: (〈0;q〉 + 1)
      q: int
    }
    incomplete7: {
      p: (〈0;q〉 + 1)
      q: int
      if false {
        q: 1
      }
    }
  }
  mixedFieldsSuccess: {
    a: {
      for _, s in [
        "foo",
      ] {
        "\(〈1;s〉)": 1
        X: 1
      }
    }
    b: {
      #Def: {
        for _, s in [
          "foo",
        ] {
          "\(〈1;s〉)": 1
          X: 1
        }
      }
    }
    b: {
      x: 〈1;b〉.#Def
    }
    b: {
      x: {
        X: _
      }
    }
    b: {
      x: {
        foo: _
      }
    }
    c: {
      #Def: {
        X: int
        foo: int
      }
    }
    c: {
      x: 〈1;c〉.#Def
    }
    c: {
      x: {
        for _, s in [
          "foo",
        ] {
          "\(〈1;s〉)": 1
          X: 1
        }
      }
    }
  }
  fieldMismatch: {
    a: {
      2
      if true {
        x: 3
      }
    }
  }
  noStackOverflowStructCycle: {
    #list: {
      tail: 〈1;#list〉
      if (〈0;tail〉 != null) {
        sum: 〈1;tail〉.sum
      }
    }
    list: {
      tail: 〈1;list〉
      if (〈0;tail〉 != null) {
        sum: 〈1;tail〉.sum
      }
    }
  }
  provideIncompleteSuccess: {
    t1: {
      #a: {
        if 〈0;b〉 {
          c: 4
        }
        b: bool
      }
      x: ((〈0;#a〉 & {
        b: true
      }) & {
        c: 4
      })
      y: 〈0;x〉
    }
    t2: {
      #a: {
        if 〈0;b〉 {
          c: 4
        }
        b: true
      }
      #c: {}
      a: {
        if 〈0;b〉 {
          c: {
            d: 4
          }
        }
        b: true
        c: 〈1;#c〉
      }
    }
  }
  voidArcs: {
    scopes: {
      x: 1
      a: {
        y: 2
        if true {
          b: 〈2;x〉
          c: {
            d: 〈3;x〉
          }
          e: 〈1;y〉
          f: {
            g: 〈2;y〉
          }
        }
      }
    }
    drop: {
      x: 1
      a: {
        y: 2
        if false {
          b: 〈2;x〉
          c: {
            d: 〈3;x〉
          }
          e: 〈1;y〉
          f: {
            g: 〈2;y〉
          }
        }
      }
    }
  }
  cyclicError: {
    a: {
      x: bool
      y: bool
      if 〈1;a〉.x {
        y: true
      }
      if 〈1;a〉.y {
        x: true
      }
      b: {}
    }
    c: 〈0;a〉.b
  }
  midwayReferences: {
    a: {
      for i, j in {
        a: 1
        b: 2
      } {
        x: {
          y: {
            z: {
              〈4;i〉: 〈4;j〉
            }
          }
        }
      }
      x: {
        y: {}
      }
    }
    b: 〈0;a〉.x
    c: 〈0;a〉.x.y
    d: 〈0;a〉.x.y.z
  }
  closedCheck: {
    success1: {
      a: {
        b: {
          [string]: 〈2;#D〉
        }
      }
      #D: {
        d: string
        if (〈0;d〉 != "c") {
          e: string
        }
      }
      a: {
        b: {
          c: {
            d: "d"
            e: "ok"
          }
        }
      }
    }
  }
  closedCheck: {
    success2: {
      a: {
        b: {
          [string]: 〈2;#D〉
        }
      }
      #D: {
        d: string
        if (〈0;d〉 != "c") {
          ("foo" + "bar"): string
        }
      }
      a: {
        b: {
          c: {
            d: "d"
            foobar: "ok"
          }
        }
      }
    }
  }
  closedCheck: {
    success3: {
      a: {
        b: {
          [string]: 〈2;#D〉
        }
      }
      #D: {
        d: string
        e: {
          if (〈1;d〉 != "c") {
            string
          }
        }
      }
      a: {
        b: {
          c: {
            d: "d"
            e: "ok"
          }
        }
      }
    }
  }
  emptyComprehensionIncomplete: {
    a: {}
    b: {
      if 〈1;a〉.b {}
    }
  }
  voidEliminationSuccess: {
    t1: {
      [string]: {
        b: bool
        if !〈0;b〉 {}
      }
      if false {
        a: {
          b: true
        }
      }
    }
  }
  voidEliminationSuccess: {
    t2: {
      components: {
        sinks: {
          [string]: (〈1;#C〉 & {
            kind: string
            configuration: {
              if (〈1;kind〉 != "source") {
                inputs: {
                  required: true
                }
              }
            }
          })
        }
        #C: {
          kind: string
          configuration: {
            [string]: {
              required: bool
              if !〈0;required〉 {
                common: bool
              }
            }
          }
        }
      }
      components: {
        sinks: {
          blah: {
            kind: "source"
          }
        }
      }
    }
  }
  voidEliminationSuccess: {
    derefRef1: {
      a: {
        [string]: {
          c: {
            [string]: 〈3;E〉
          }
        }
      }
      a: {
        b: {
          c: {
            if false {
              d: {
                e: true
              }
            }
          }
        }
      }
      E: {
        e: bool
        f: !〈0;e〉
      }
    }
  }
  voidEliminationSuccess: {
    derefRef2: {
      a: {
        [string]: {
          c: {
            [string]: 〈3;E〉
          }
        }
      }
      a: {
        b: {
          c: {
            if false {
              d: {
                e: true
              }
            }
          }
        }
      }
      E: 〈0;#F〉
      #F: {
        e: bool
        f: !〈0;e〉
      }
    }
  }
  voidEliminationSuccess: {
    derefDisj1: {
      a: {
        [string]: {
          c: {
            [string]: 〈3;E〉
          }
        }
      }
      a: {
        b: {
          c: {
            if false {
              d: {
                e: true
              }
            }
          }
        }
      }
      E: ({
        e: bool
        f: !〈0;e〉
      }|{
        g: bool
        h: !〈0;g〉
      })
    }
  }
  voidEliminationSuccess: {
    derefDisj2: {
      a: {
        [string]: {
          c: {
            [string]: (〈3;E〉 & 〈3;E〉)
          }
        }
      }
      a: {
        b: {
          c: {
            if false {
              d: {
                e: true
              }
            }
          }
        }
      }
      E: ({
        e: bool
        f: !〈0;e〉
      }|{
        g: bool
        h: !〈0;g〉
      })
    }
  }
  voidEliminationSuccess: {
    bulk1: {
      a: {
        b: {}
      }
      a: {
        [string]: {
          c: {
            e: string
            if false {
              e: ""
            }
          }
          d: 〈0;c〉.e
        }
      }
    }
  }
  voidEliminationSuccess: {
    opt1: {
      a: {
        b: {}
      }
      a: {
        b?: {
          c: {
            e: string
            if false {
              e: ""
            }
          }
          d: 〈0;c〉.e
        }
      }
    }
  }
  voidEliminationSuccess: {
    noCycle1: {
      _x: 〈0;a〉.b
      a: {
        c: {
          h: "stream"
        }
        b: {
          if (〈1;c〉.g != _|_(explicit error (_|_ literal) in source)) {}
        }
        c: {
          if false {
            g: _
          }
        }
      }
    }
  }
  voidEliminationSuccess: {
    noCycle2: {
      a: {
        c: {
          h: "stream"
        }
        b: {
          if (〈1;c〉.g != _|_(explicit error (_|_ literal) in source)) {}
        }
        c: {
          if false {
            g: _
          }
        }
      }
      _x: 〈0;a〉.b
    }
  }
  voidLookup: {
    a: {
      x: {
        z: 〈2;a〉.y.z.void
      }
    }
    a: {
      y: {
        c: _
        z: {}
      }
    }
    a: {
      [string]: {
        c: {
          for k, v in 〈1;z〉 {
            〈1;k〉: null
          }
        }
        z: {
          if false {
            err: {}
          }
        }
      }
    }
  }
  topElimination: {
    a: int
    _
    if true {
      x: (〈1;a〉 + 1)
    }
  }
  voidEliminationSuccess: {
    drop1: {
      t: {
        #ok: (*true|bool)
        if 〈0;#ok〉 {
          x: int
        }
      }
      s: (〈0;t〉 & {
        #ok: false
      })
    }
  }
  explicitDefaultError: {
    a: (string|*_|_(explicit error (_|_ literal) in source))
    if (〈0;a〉 != "") {}
  }
  allArcsSuccess: {
    p1: {
      x: {
        for k, _ in 〈1;y〉 {
          〈1;k〉: null
        }
      }
      y: {
        if false {
          x: {}
        }
      }
    }
  }
  allArcsSuccess: {
    p2: {
      y: {
        if false {
          x: {}
        }
      }
      x: {
        for k, _ in 〈1;y〉 {
          〈1;k〉: null
        }
      }
    }
  }
  structShare: {
    ok1: {
      a: {
        [string]: 〈1;E〉
      }
      E: {}
      a: {
        if true {
          d: {
            e: true
          }
        }
      }
    }
  }
  structShare: {
    err1: {
      x: {
        [string]: 〈1;x〉.#E
      }
      x: {
        #E: {}
      }
      if true {
        x: {
          d: {
            e: true
          }
        }
      }
    }
  }
}
--- issue1759.cue
{
  unity: {
    success1: {
      #Config: {
        name: string
        type: string
      }
      #AnyConfig: {
        〈1;#Config〉
        ...
      }
      #Env: {
        name: string
        configurations: {
          [string]: 〈2;#AnyConfig〉
        }
      }
      envs: {
        e1: (〈1;#Env〉 & {
          configurations: {
            c1: 〈3;#Config〉
          }
        })
      }
      envs: {
        [string]: {
          configurations: {
            [string]: {
              type: "foo"
              if (〈0;type〉 == "terraform") {
                backend: {
                  type: "s3"
                }
              }
            }
          }
        }
      }
    }
  }
  issue1759: {
    _ports_map: {}
    if (len(〈0;_ports_map〉) > 0) {
      port: 〈1;_ports_map〉.a.port
    }
    if true {
      _ports_map: {
        a: {
          port: "80"
        }
      }
    }
  }
  arcAlignment: {
    t1: {
      [string]: {
        if true {}
      }
      if false {
        c: _
      }
    }
  }
}
--- issue2111.cue
{
  letPushdown: {
    _c: {
      y: 1
    }
    a: {
      for k, v in 〈1;_c〉 {
        let x#1multi = 〈1;v〉
        if (〈0;let x#1〉 != _|_(explicit error (_|_ literal) in source)) {}
      }
    }
  }
}
--- issue2113.cue
{
  nestedWithEmbeddingOK: {
    c: [
      1,
    ]
    a: {
      for k, v in 〈1;c〉 {
        {
          x: 1
        }
        if (〈3;a〉.x != _|_(explicit error (_|_ literal) in source)) {}
      }
    }
  }
  nestedWithDynamicFieldOK: {
    _c: {
      y: 1
    }
    a: {
      for k, v in 〈1;_c〉 {
        if (〈0;("\(〈1;k〉)")〉 != _|_(explicit error (_|_ literal) in source)) {}
        "\(〈1;k〉)": 1
      }
    }
  }
  errorPropagation: {
    deployment: _
    for k, v in 〈0;deployment〉 {
      for k1, v2 in 〈1;v〉.env2 {
        deployment: {
          〈4;k〉: {
            x1: 1
          }
        }
      }
    }
    for _, id in [
      "elem",
    ] {
      deployment: {
        〈2;id〉: {
          x2: 2
        }
      }
    }
  }
}
--- issue2131.cue
{
  issue2131: {
    tests: {
      windows: {
        eg1: {
          in: "c:\\d"
        }
        eg2: {
          in: "c:\\test"
        }
        eg3: {
          in: "c:\\test\\d"
        }
      }
      for os, examples in 〈1;tests〉 for k, v in 〈0;examples〉 {
        〈2;os〉: {
          〈2;k〉: {
            out: "test"
          }
        }
      }
    }
  }
}
--- issue2208.cue
{
  voidErrorIncomplete: {
    #Schema: {
      [string]: {
        required: bool
        if !〈0;required〉 {}
      }
    }
    root: 〈0;#Schema〉
    root: {
      if false {
        child: {
          required: false
        }
      }
    }
  }
}
--- issue3533.cue
{
  issue3533: {
    #ObjectMeta: {
      namespace?: string
    }
    out: {
      for i, _ in [
        "iter-once",
      ] {
        metadata: 〈3;#ObjectMeta〉
        if false {
          metadata: {
            namespace: "foo"
          }
        }
      }
    }
    out: {
      metadata: {
        namespace: (*"default"|string)
      }
    }
  }
}
--- issue3535.cue
{
  issue3535: {
    hidden: {
      #X: {
        kind: string
        output: {}
      }
      foo: (〈0;#X〉 & {
        kind: string
        if (〈0;kind〉 == "foo") {
          _hidden: {}
        }
      })
      foo: {
        kind: "foo"
      }
    }
  }
  issue3535: {
    regular: {
      #X: {
        kind: string
        output: {}
      }
      foo: (〈0;#X〉 & {
        kind: string
        if (〈0;kind〉 == "foo") {
          regular: {}
        }
      })
      foo: {
        kind: "foo"
      }
    }
  }
  issue3535: {
    def: {
      #X: {
        kind: string
        output: {}
      }
      foo: (〈0;#X〉 & {
        kind: string
        if (〈0;kind〉 == "foo") {
          #def: {}
        }
      })
      foo: {
        kind: "foo"
      }
    }
  }
}
--- issue3621.cue
{
  issue3621: {
    reduced: {
      t1: {
        if true {
          a: 〈0;b1〉.b2.b3
          b1: {
            b2: {
              b3: "Foo"
            }
          }
        }
      }
    }
  }
  issue3621: {
    reduced: {
      t2: {
        outer: {}
        if true {
          inner: {
            inner2: {
              name: "Foo"
            }
          }
          outer: {
            b: 〈1;inner〉.inner2.name
          }
        }
      }
    }
  }
  issue3621: {
    full: {
      hello: "world"
      outer: {
        [string]: {
          name: 〈1;-〉
        }
      }
      if true {
        inner: {
          inner2: {
            name: "Employees"
            description: "All employees"
            privacy: "secret"
            create_default: false
          }
        }
        outer: {
          outer2: {
            bar: 〈2;inner〉.inner2.name
          }
        }
      }
    }
  }
}
--- issue3708.cue
{
  issue3708: {
    out: 〈0;people〉.bob.kind
    people: {
      [string]: {
        kind: "person"
        name?: string
      }
    }
    if true {
      people: {
        bob: {
          name: "Bob"
        }
      }
    }
  }
}
--- issue3729.cue
{
  issue3729: {
    withDisjunction: {
      #Root: {
        sub1?: {
          #sub2?: bool
        }
      }
      root?: (null|〈0;#Root〉)
      if true {
        root: {
          sub1?: {
            #sub2: true
          }
        }
      }
    }
  }
  issue3729: {
    withoutDisjunction: {
      root?: null
      if true {
        root: {
          #sub1?: {
            #sub2: true
          }
        }
      }
    }
  }
  issue3729: {
    withoutDisjunctionWithEmbed: {
      root?: null
      if true {
        root: {
          _
          #sub1?: {
            #sub2: true
          }
        }
      }
    }
  }
  issue3729: {
    definitionsOnly: {
      #Root: {
        #sub1?: {
          #sub2?: bool
        }
      }
      root?: (null|〈0;#Root〉)
      if true {
        root: {
          #sub1?: {
            #sub2: true
          }
        }
      }
    }
  }
  issue3729: {
    withEmbed: {
      incomplete: {
        #Root: {
          #sub1?: {
            #sub2?: bool
          }
        }
        root?: (null|〈0;#Root〉)
        if true {
          root: {
            _
            #sub1?: {
              #sub2: true
            }
          }
        }
      }
    }
  }
  issue3729: {
    full: {
      #Application: {
        spec: 〈1;#ApplicationSpec〉
      }
      #ApplicationSpec: {
        syncPolicy?: (null|〈1;#SyncPolicy〉)
      }
      #SyncPolicy: {
        automated?: (null|〈1;#SyncPolicyAutomated〉)
      }
      #SyncPolicyAutomated: {
        prune?: bool
        selfHeal?: bool
      }
      argoApp: (〈0;#Application〉 & {
        spec: {
          if true {
            syncPolicy: {
              automated: {
                prune: true
                selfHeal: true
              }
            }
          }
        }
      })
      argoApp: {
        spec: {
          _syncpolicy: "selfhealprune"
        }
      }
    }
  }
}
--- issue3935.cue
{
  issue3935: {
    reduced: {
      out: (〈0;#A〉|〈0;#B〉)
      out: (〈0;#B〉 & {
        y: {
          x: "bar"
        }
      })
      #A: {
        y: {
          other: int
        }
      }
      #B: {
        if true {
          x: 〈1;y〉.x
        }
        y!: {
          x!: _
        }
      }
    }
  }
  issue3935: {
    full: {
      out: (〈0;#SchemaOther〉|〈0;#SchemaSelected〉)
      out: (〈0;#SchemaSelected〉 & {
        spec: {
          name: "foo"
          config: {
            namespace: "bar"
          }
        }
      })
      #SchemaOther: {
        spec: {
          otherOptional?: int
          otherRegular: int
          otherRequired!: int
        }
      }
      #SchemaSelected: {
        spec!: {
          name!: string
          config!: _
        }
        if true {
          namespace: 〈1;_specConfig〉.namespace
        }
        _specConfig: 〈0;spec〉.config
      }
    }
  }
}
--- pending.cue
{
  arcTypeAcrossTwo: {
    a?: {
      b?: ({
        c?: (null|{})
      }|null)
    }
    if true {
      a: {
        b: {
          c: {
            d: true
          }
        }
      }
    }
  }
  issue3894: {
    reduced: {
      p1: {
        ({
          a: string
        }|{
          b: {
            value: string
          }
        })
        if true {
          b: {
            value: "true"
          }
        }
      }
    }
  }
  issue3894: {
    reduced: {
      p2: {
        ({
          b: {
            value: string
          }
        }|{
          a: string
        })
        if true {
          b: {
            value: "true"
          }
        }
      }
    }
  }
  issue3894: {
    full: {
      #Output: ({
        a?: string
      }|{
        b?: {
          value: string
        }
      })
      out: 〈0;#Output〉
      out: {
        if (true == true) {
          b: {
            value: "true"
          }
        }
      }
    }
  }
}
--- reflect.cue
{
  unifyDynamicReflectSuccess: {
    for _, s in [
      "foo",
    ] {
      X: {
        ...
      }
      "\(〈1;s〉)": {
        X: {
          ...
        }
        Y: 〈import;"encoding/json"〉.Marshal(〈0;X〉)
      }
    }
    [string]: {
      X: {
        if true {
          x: {
            y: {}
          }
        }
      }
    }
  }
}
