// Ensure that disjunction elimination is not done prematurely.

// Issue #651

-- in.cue --
import "struct"

// Closedness checks should not be triggered too early, or with an improper
// subset of StructInfos. Blindly finalizing partial disjuncts will end up
// doing a closedness check with not all embeddings present, which can lead to
// a field being rejected prematurely.
//
// It should be recursively disabled.
disambiguateClosed: {
	b: #Def & a
	a: #Def
	#Def: {{x: true} | {y: true}}
}

// Checks should never be disabled for field matching.
alwaysCheckMatchers1: {
	b: {[=~"^xxxx$"]: int} | null
	b: {c:            string} | null
	b: c: "yyyyy"
}

alwaysCheckPatterns2: {
	a: #X
	a: b

	b: #X
	b: c: "yyyyy"

	#X: string | {
		c: string
		{[=~"^xxxx$"]: int}
	}
}

nestedNonMonotonic: resolved: n1: {
	x: {a:    struct.MinFields(2)} | null
	x: {a: c: 1} | null
	x: {a: d: 1} | null
}

nestedNonMonotonic: resolved: n2: {
	x: {a: b:    struct.MinFields(2)} | null
	x: {a: b: c: 1} | null
	x: {a: b: d: 1} | null
}

nestedNonMonotonic: eliminated: n1: p1: {
	x: {a:    struct.MaxFields(1)} | null
	x: {a: c: 1} | null
	x: {a: d: 1} | null
}

nestedNonMonotonic: eliminated: n1: p2: {
	x: {a: c: 1} | null
	x: {a:    struct.MaxFields(1)} | null
	x: {a: d: 1} | null
}

nestedNonMonotonic: eliminated: n1: p2: {
	x: {a: c: 1} | null
	x: {a: d: 1} | null
	x: {a:    struct.MaxFields(1)} | null
}

nestedNonMonotonic: eliminated: n2: p1: {
	x: {a: b:    struct.MaxFields(1)} | null
	x: {a: b: c: 1} | null
	x: {a: b: d: 1} | null
}

nestedNonMonotonic: eliminated: n2: p2: {
	x: {a: b: c: 1} | null
	x: {a: b:    struct.MaxFields(1)} | null
	x: {a: b: d: 1} | null
}

nestedNonMonotonic: eliminated: n2: p2: {
	x: {a: b: c: 1} | null
	x: {a: b: d: 1} | null
	x: {a: b:    struct.MaxFields(1)} | null
}

// TODO: should be incomplete.
nestedNonMonotonic: incomplete: a: n1: p1: {
	x: {a:    struct.MinFields(2)} | null
	x: {a: c: 1} | null
}

// TODO: should be incomplete.
nestedNonMonotonic: incomplete: a: n1: p2: {
	x: {a: c: 1} | null
	x: {a:    struct.MinFields(2)} | null
}

nestedNonMonotonic: incomplete: a: n2: p1: {
	x: {a: b:    struct.MinFields(2)} | null
	x: {a: b: c: 1} | null
}

nestedNonMonotonic: incomplete: a: n2: p2: {
	x: {a: b: c: 1} | null
	x: {a: b:    struct.MinFields(2)} | null
}

nestedNonMonotonic: incomplete: b: n1: p1: {
	x: {a:    struct.MinFields(3)} | null
	x: {a: c: 1} | null
	x: {a: d: 1} | null
}

nestedNonMonotonic: incomplete: b: n1: p2: {
	x: {a: c: 1} | null
	x: {a:    struct.MinFields(3)} | null
	x: {a: d: 1} | null
}

nestedNonMonotonic: incomplete: b: n1: p3: {
	x: {a: c: 1} | null
	x: {a: d: 1} | null
	x: {a:    struct.MinFields(3)} | null
}

nestedNonMonotonic: incomplete: b: n2: p1: {
	x: {a: b:    struct.MinFields(3)} | null
	x: {a: b: c: 1} | null
	x: {a: b: d: 1} | null
}

nestedNonMonotonic: incomplete: b: n2: p1: {
	x: {a: b: c: 1} | null
	x: {a: b:    struct.MinFields(3)} | null
	x: {a: b: d: 1} | null
}

nestedNonMonotonic: incomplete: b: n2: p1: {
	x: {a: b: c: 1} | null
	x: {a: b: d: 1} | null
	x: {a: b:    struct.MinFields(3)} | null
}

preserveClosedness: small: p1: {
	#A: #B & {a: string}
	#B: {
		*{} | {a: string}
		*{} | {b: int}
	}
}

preserveClosedness: small: p2: {
	#A: #B & {a: string}
	#B: {
		{a: string} | *{}
		*{} | {b: int}
	}
}

preserveClosedness: medium: p1: {
	#A: #B & {a: string}
	#B: {
		*{} | {a: string} | {b: string}
		*{} | {c: int} | {d: string}
	}
}

preserveClosedness: medium: p2: {
	#A: #B & {a: string}
	#B: {
		{a: string} | *{} | {b: string}
		*{} | {c: int} | {d: string}
	}
}

preserveClosedness: medium: p3: {
	#A: #B & {a: string}
	#B: {
		{a: string} | {b: string} | *{}
		*{} | {c: int} | {d: string}
	}
}

// If an error occurred in the last disjunction, it may sometimes be propagated
// to parent nodes. This, in turn, could lead to references to such field
// to fail with that error.
noChildError: _
noChildError: issue1608: {
	myValue: #type & {fieldName: "some string"}
	#type: fieldName: #subtype

	#subtype: string | {foo: string} | {bar: #subtype}
}

noChildError: t1: {
	#D: {b: string} | {c: #D }
	o: #D & {b: "test"}
}

noChildError: t2: {
	o: #D & {b: "test"}
	#D: {b: string} | {c: #D }
}

noChildError: t3: {
	#D: {a: null} | {b: string} | {c: #D }
	o: #D & {b: "test"}
}

noChildError: t4: {
	o: #D & {b: "test"}
	#D: {a: null} | {b: string} | {c: #D }
}


issue1924: t1: {
	m: a: 2
	x: *[m.b] | 2
}
issue1924: t2: {
	m: a: 2
	x: *{v: m.b} | 3
}
issue1924: t3: {
	m: a: 2
	x: *m.b | 1
}

// should eliminate erroneous comprehension and pass
issue1838: t1: {
	p?: []
	a: [for k in p {k}] | null
}
issue1838: t2: {
	p?: []
	a: null | [for k in p {k}]
}

noHang: {
	// This should terminate.
	#T: ["a", #T] | ["d", ...#T]

	x: #T

	#X: x
	#X: #T
}

issue1940: {
	#T: ["a", #T] | ["b", #T] | ["c", #T] | ["d", [...#T]]

	#A: type: #T

	#B: [string]: #A

	#C: #B & {
		x: #A
	}
}

-- issue2209full.cue --
// TODO: fix

issue2209: simplified: t1: {
	#SpecFoo: foo: min: 1
	#SpecBar: bar: min: 1
	spec: bar: {}
	spec:  #SpecFoo | #SpecBar
	out: {
		{nullFoo: null} | {nullBar: null}
		{minFoo: int} | {minBar: int}
		if X.bar != _|_ {
			minBar: X.bar.min
		}
		X: spec
	}
}

issue2209: simplified: t2: {
	#SpecFoo: foo: {}
	#SpecBar: bar: x: 1
	spec: bar: {}
	spec: *#SpecFoo | #SpecBar
	if spec.bar != _|_ {
		BAZ: spec.bar.x
	}
	{f1: int} | {b2: int}
	{f2: int} | {b2: int}
}

// This test fails for 0.4 and 0.5.
issue2209: simplified: t3: {
	#A: v: 1
	{f1: int} | {b2: int}
	{f2: int} | {b2: int}
	BAZ: S.y
	S: *#A | #B
	#B: {x: 1, y: 1}
	S: x: 1
}

issue2209: full: {
	Foo: #Abstract & {spec: foo: {}}
	Bar: #Abstract & {spec: bar: {}}

	#Abstract: X={
		spec: _#Spec

		resource: _Thing & {_X: spec: X.spec}
	}

	_#Spec: *_#SpecFoo | _#SpecBar

	_#SpecFoo: {
		foo: {
			min: int | *10
			max: int | *20
		}
	}

	_#SpecBar: {
		bar: {
			min: int | *30
			max: int | *40
		}
	}

	_Thing: #Constrained & {
		_X: _

		spec: {
			if _X.spec.foo != _|_ {
				minFoo: _X.spec.foo.min
				maxFoo: _X.spec.foo.max
			}

			if _X.spec.bar != _|_ {
				minBar: _X.spec.bar.min
				maxBar: _X.spec.bar.max
			}
		}
	}

	#Constrained: #Base & {
		spec: {
			minFoo:  int | *10
			maxFoo:  int | *20
			minBar?: null
			maxBar?: null
		} | {
			minBar:  int | *30
			maxBar:  int | *40
			minFoo?: null
			maxFoo?: null
		}

		spec: *{
			fuga?: null
		} | {
			hoge?: null
		}
	}

	#Base: {
		spec: {
			minFoo?: null | int
			maxFoo?: null | int
			minBar?: null | int
			maxBar?: null | int

			hoge?: null | bool
			fuga?: null | bool
		}
	}
}


-- issue2246.cue --
issue2246: simplified: {
	#FormFoo: fooID: string
	#FormBar: barID: string
	#Form: { #FormFoo | #FormBar }

	data: {fooID: "123"}
	out1: #Form & data
	out2: #Form & out1
}
issue2246: full: {
	data: forms: [{
		fooID: "00-0000001"
	}]

	form1040: (#compute & {in: data}).out

	#K1: {
		#_base: common: 3
		#FormFoo: {
			#_base
			fooID: string
		}
		#FormBar: {
			#_base
			barID: string
		}
		#Form: {
			#FormFoo | #FormBar
		}
	}

	#Input: {
		forms: [...#K1.#Form]
	}

	#summarizeReturn: {
		in:  #Input
		out: [for k in in.forms { k.common }]
	}

	#compute: {
		in:  #Input
		out: (#summarizeReturn & {"in": in}).out
	}
}

-- issue2263.cue --
issue2263: simplified: {
	metrics: #Metric
	#Metric: {
		#IDSource | {}
		#TargetAverage | {}
	}

	metrics: {
		id:  "foo"
		avg: 60
	}

	#IDSource: id: string
	#TargetAverage: avg: number
}
issue2263: full: {
	metrics: [...#Metric]

	metrics: [{
		id:  "foo"
		avg: 60
	}, {
		id:    "bar"
		value: 80
	}, {
		uri: "baz"
		avg: 70
	}, {
		uri:   "qux"
		value: 90
	}]

	#Metric: {
		#Source
		#Target
	}

	#Source:
		#IDSource |
		#URISource

	#Target:
		#TargetAverage |
		#TargetValue

	#IDSource: {
		id: string
	}

	#URISource: {
		uri: string
	}

	#TargetAverage: {
		avg: number
	}

	#TargetValue: {
		value: number
	}
}
-- issue1417.cue --
issue1417: {
	#ID: !~"^a" | =~"^ab$" | =~"^aB$"
	#ID: =~"^a" | !~"[A-Z]"
	ids: [...#ID] & ["xyz", "ab", "aB"]
}
-- issue3149.cue --
issue3149: {
	#valid: {
		name!: ( (=~"^Foo") | "an exception") & ( (=~"Foo$") | "an exception")
	}
	list: [...#valid]
	list: [
		{name: "FooBarFoo"},
		{name: "FooBazFoo"},
		{name: "FooQuuxFoo"},
		{name: "an exception"},
	]
}
-- issue770.cue --
issue770: {
	#A: {
		v: "a" | "b" | "c"
	}
	h: [string]: #A
	h: a: {
		v: *"a" | string
	}
	h: [=~"^b"]: {
		v: *h.a.v | string
	}
	h: [=~"^c"]: {
		v: *h.b.v | string
	}
	h: b:   _
	h: boo: _
	h: c:   _
	h: coo: _
}
-- issue3528.cue --
issue3528: original: {
	workflows: [...#Workflow]
	workflows: [test]

	test: #Workflow & {}

	#Workflow: {
		container: [string]: string | #container
		#container: string | {volumes?: [...string]}
	}
}
issue3528: reduced: {
	a?: #A
	a:  #A & {}
	#A: {
		A: [string]: 1 | #a
		#a: 2 | {v: 1}
	}
}
issue3528: counter: {
}
issue3528: nested: t1: {
	{v: 1} | (2 | 3)
	{v: 1} | (2 | 3)
	{v: 1} | (2 | 3)
	{v: 1} | (2 | 3)
}
issue3528: nested: t2: {
	{v: 1} | 2
	{v: 1} | (2 | 3)
	{v: 1} | 2
	{v: 1} | 2
}
-- issue3784.cue --
issue3784: reduced: {
	#Schema: a: {
		kind: "A"
		b: c?: string
		b: {}
	} | {
		kind: "B"
	}
	
	out: #Schema
	out: a: {
		kind: "A"
		b: c: "x"
	}
}
issue3784: full: {
	#Schema: {
		pages?: {
			build_type?: "legacy" | "workflow"
			source?: {
				branch?: string
				path?:   string
			}
			cname?: string
		}
		pages?: {
			build_type!: "legacy"
			source!: {
				branch!: _
			}
		} | close({
			build_type!: "workflow"
			cname?:      _
		})
	}
	out: #Schema & {
		pages: {
			cname:      "foo.com"
			build_type: "legacy"
			source: {
				branch: "main"
				path:   "/"
			}
		}
	}
}
issue3784: variant1: {
	#Schema: {
		pages: {
			build_type?: "legacy" | "workflow"
			source: {
				branch?: string
				path?:   string
			}
			cname?: string
		}
		pages?: {
			build_type!: "legacy"
			source!: {
				branch!: _
			}
		} | close({
			build_type!: "workflow"
			cname?:      _
		})
	}
}
issue3784: variant2: {
	#Schema: {
		build_type!: "legacy"
		source!: {
			branch!: _
		}
	} | close({
		build_type!: "workflow"
		cname?:      _
	})
	a: #Schema
	a: {
		build_type?: "legacy" | "workflow"
		source: {
			branch?: string
			path?:   string
		}
		cname?: string
	}
}
-- issue3958.cue --
issue3958: t1: {
	#schema: int | *1
	#schema: int | *3

	test1: #schema & {int | *2}
	test2: #schema & {int | *4}
}
issue3958: t2: {
 	a: (int | *4) & (int | *1) & (int | *3) & (int | *8)
	b: (int | *4) & (int | *1) & (int | *3)
}
-- out/evalalpha --
(struct){
  disambiguateClosed: (struct){
    b: (#struct){ |((#struct){
        x: (bool){ true }
      }, (#struct){
        y: (bool){ true }
      }) }
    a: (#struct){ |((#struct){
        x: (bool){ true }
      }, (#struct){
        y: (bool){ true }
      }) }
    #Def: (#struct){ |((#struct){
        x: (bool){ true }
      }, (#struct){
        y: (bool){ true }
      }) }
  }
  alwaysCheckMatchers1: (struct){
    b: (struct){
      c: (string){ "yyyyy" }
    }
  }
  alwaysCheckPatterns2: (struct){
    a: (#struct){
      c: (string){ "yyyyy" }
    }
    b: (#struct){
      c: (string){ "yyyyy" }
    }
    #X: ((string|struct)){ |((string){ string }, (#struct){
        c: (string){ string }
      }) }
  }
  nestedNonMonotonic: (struct){
    resolved: (struct){
      n1: (struct){
        x: ((null|struct)){ |((struct){
            a: (struct){
              c: (int){ 1 }
              d: (int){ 1 }
            }
          }, (null){ null }) }
      }
      n2: (struct){
        x: ((null|struct)){ |((struct){
            a: (struct){
              b: (struct){
                c: (int){ 1 }
                d: (int){ 1 }
              }
            }
          }, (null){ null }) }
      }
    }
    eliminated: (struct){
      n1: (struct){
        p1: (struct){
          x: (null){ null }
        }
        p2: (struct){
          x: (null){ null }
        }
      }
      n2: (struct){
        p1: (struct){
          x: (null){ null }
        }
        p2: (struct){
          x: (null){ null }
        }
      }
    }
    incomplete: (struct){
      a: (struct){
        n1: (struct){
          p1: (struct){
            x: (null){ null }
          }
          p2: (struct){
            x: (null){ null }
          }
        }
        n2: (struct){
          p1: (struct){
            x: ((null|struct)){ |((struct){
                a: (struct){
                  b: (_|_){
                    // [incomplete] nestedNonMonotonic.incomplete.a.n2.p1.x.a.b: invalid value {c:1} (does not satisfy struct.MinFields(2)): len(fields) < MinFields(2) (1 < 2):
                    //     ./in.cue:96:15
                    //     ./in.cue:96:32
                    //     ./in.cue:97:12
                    c: (int){ 1 }
                  }
                }
              }, (null){ null }) }
          }
          p2: (struct){
            x: ((null|struct)){ |((struct){
                a: (struct){
                  b: (_|_){
                    // [incomplete] nestedNonMonotonic.incomplete.a.n2.p2.x.a.b: invalid value {c:1} (does not satisfy struct.MinFields(2)): len(fields) < MinFields(2) (1 < 2):
                    //     ./in.cue:102:15
                    //     ./in.cue:101:12
                    //     ./in.cue:102:32
                    c: (int){ 1 }
                  }
                }
              }, (null){ null }) }
          }
        }
      }
      b: (struct){
        n1: (struct){
          p1: (struct){
            x: (null){ null }
          }
          p2: (struct){
            x: (null){ null }
          }
          p3: (struct){
            x: (null){ null }
          }
        }
        n2: (struct){
          p1: (struct){
            x: ((null|struct)){ |((struct){
                a: (struct){
                  b: (_|_){
                    // [incomplete] nestedNonMonotonic.incomplete.b.n2.p1.x.a.b: invalid value {c:1,d:1} (does not satisfy struct.MinFields(3)): len(fields) < MinFields(3) (2 < 3):
                    //     ./in.cue:138:15
                    //     ./in.cue:124:15
                    //     ./in.cue:125:12
                    //     ./in.cue:126:12
                    //     ./in.cue:130:12
                    //     ./in.cue:131:15
                    //     ./in.cue:132:12
                    //     ./in.cue:136:12
                    //     ./in.cue:137:12
                    //     ./in.cue:138:32
                    c: (int){ 1 }
                    d: (int){ 1 }
                  }
                }
              }, (null){ null }) }
          }
        }
      }
    }
  }
  preserveClosedness: (struct){
    small: (struct){
      p1: (struct){
        #A: (#struct){ |(*(#struct){
            a: (string){ string }
          }, (#struct){
            a: (string){ string }
            b: (int){ int }
          }) }
        #B: (#struct){ |(*(#struct){
          }, (#struct){
            b: (int){ int }
          }, (#struct){
            a: (string){ string }
          }, (#struct){
            a: (string){ string }
            b: (int){ int }
          }) }
      }
      p2: (struct){
        #A: (#struct){ |(*(#struct){
            a: (string){ string }
          }, (#struct){
            a: (string){ string }
            b: (int){ int }
          }) }
        #B: (#struct){ |(*(#struct){
          }, (#struct){
            a: (string){ string }
            b: (int){ int }
          }, (#struct){
            a: (string){ string }
          }, (#struct){
            b: (int){ int }
          }) }
      }
    }
    medium: (struct){
      p1: (struct){
        #A: (#struct){ |(*(#struct){
            a: (string){ string }
          }, (#struct){
            a: (string){ string }
            c: (int){ int }
          }, (#struct){
            a: (string){ string }
            d: (string){ string }
          }) }
        #B: (#struct){ |(*(#struct){
          }, (#struct){
            c: (int){ int }
          }, (#struct){
            d: (string){ string }
          }, (#struct){
            a: (string){ string }
          }, (#struct){
            a: (string){ string }
            c: (int){ int }
          }, (#struct){
            a: (string){ string }
            d: (string){ string }
          }, (#struct){
            b: (string){ string }
          }, (#struct){
            b: (string){ string }
            c: (int){ int }
          }, (#struct){
            b: (string){ string }
            d: (string){ string }
          }) }
      }
      p2: (struct){
        #A: (#struct){ |(*(#struct){
            a: (string){ string }
          }, (#struct){
            a: (string){ string }
            c: (int){ int }
          }, (#struct){
            a: (string){ string }
            d: (string){ string }
          }) }
        #B: (#struct){ |(*(#struct){
          }, (#struct){
            a: (string){ string }
            c: (int){ int }
          }, (#struct){
            a: (string){ string }
            d: (string){ string }
          }, (#struct){
            a: (string){ string }
          }, (#struct){
            c: (int){ int }
          }, (#struct){
            d: (string){ string }
          }, (#struct){
            b: (string){ string }
          }, (#struct){
            b: (string){ string }
            c: (int){ int }
          }, (#struct){
            b: (string){ string }
            d: (string){ string }
          }) }
      }
      p3: (struct){
        #A: (#struct){ |(*(#struct){
            a: (string){ string }
          }, (#struct){
            a: (string){ string }
            c: (int){ int }
          }, (#struct){
            a: (string){ string }
            d: (string){ string }
          }) }
        #B: (#struct){ |(*(#struct){
          }, (#struct){
            a: (string){ string }
            c: (int){ int }
          }, (#struct){
            a: (string){ string }
            d: (string){ string }
          }, (#struct){
            b: (string){ string }
          }, (#struct){
            b: (string){ string }
            c: (int){ int }
          }, (#struct){
            b: (string){ string }
            d: (string){ string }
          }, (#struct){
            a: (string){ string }
          }, (#struct){
            c: (int){ int }
          }, (#struct){
            d: (string){ string }
          }) }
      }
    }
  }
  noChildError: (struct){
    issue1608: (struct){
      myValue: (#struct){
        fieldName: (string){ "some string" }
      }
      #type: (#struct){
        fieldName: ((string|struct)){ |((string){ string }, (#struct){
            foo: (string){ string }
          }) }
      }
      #subtype: ((string|struct)){ |((string){ string }, (#struct){
          foo: (string){ string }
        }) }
    }
    t1: (struct){
      #D: (#struct){
        b: (string){ string }
      }
      o: (#struct){
        b: (string){ "test" }
      }
    }
    t2: (struct){
      o: (#struct){
        b: (string){ "test" }
      }
      #D: (#struct){
        b: (string){ string }
      }
    }
    t3: (struct){
      #D: (#struct){ |((#struct){
          a: (null){ null }
        }, (#struct){
          b: (string){ string }
        }) }
      o: (#struct){
        b: (string){ "test" }
      }
    }
    t4: (struct){
      o: (#struct){
        b: (string){ "test" }
      }
      #D: (#struct){ |((#struct){
          a: (null){ null }
        }, (#struct){
          b: (string){ string }
        }) }
    }
  }
  issue1924: (struct){
    t1: (struct){
      m: (struct){
        a: (int){ 2 }
      }
      x: (int){ 2 }
    }
    t2: (struct){
      m: (struct){
        a: (int){ 2 }
      }
      x: (int){ 3 }
    }
    t3: (struct){
      m: (struct){
        a: (int){ 2 }
      }
      x: (int){ 1 }
    }
  }
  issue1838: (struct){
    t1: (struct){
      p?: (#list){
      }
      a: (null){ null }
    }
    t2: (struct){
      p?: (#list){
      }
      a: (null){ null }
    }
  }
  noHang: (struct){
    #T: (list){
      0: (string){ "d" }
    }
    x: ~(noHang.#T)
    #X: ~(noHang.#T)
  }
  issue1940: (struct){
    #T: (#list){
      0: (string){ "d" }
      1: (list){
      }
    }
    #A: (#struct){
      type: ~(issue1940.#T)
    }
    #B: (#struct){
    }
    #C: (#struct){
      x: ~(issue1940.#A)
    }
  }
  issue1417: (struct){
    #ID: (string){ |((string){ &(!~"^a", =~"^a") }, (string){ &(!~"^a", !~"[A-Z]") }, (string){ &(=~"^ab$", =~"^a") }, (string){ &(=~"^ab$", !~"[A-Z]") }, (string){ &(=~"^aB$", =~"^a") }, (string){ &(=~"^aB$", !~"[A-Z]") }) }
    ids: (#list){
      0: (string){ "xyz" }
      1: (string){ "ab" }
      2: (string){ "aB" }
    }
  }
  issue2209: (struct){
    simplified: (struct){
      t1: (struct){
        #SpecFoo: (#struct){
          foo: (#struct){
            min: (int){ 1 }
          }
        }
        #SpecBar: (#struct){
          bar: (#struct){
            min: (int){ 1 }
          }
        }
        spec: (#struct){
          bar: (#struct){
            min: (int){ 1 }
          }
        }
        out: (struct){ |((struct){
            minBar: (int){ 1 }
            X: ~(issue2209.simplified.t1.spec)
            nullFoo: (null){ null }
            minFoo: (int){ int }
          }, (struct){
            minBar: (int){ 1 }
            X: ~(issue2209.simplified.t1.spec)
            nullFoo: (null){ null }
          }, (struct){
            minBar: (int){ 1 }
            X: ~(issue2209.simplified.t1.spec)
            nullBar: (null){ null }
            minFoo: (int){ int }
          }, (struct){
            minBar: (int){ 1 }
            X: ~(issue2209.simplified.t1.spec)
            nullBar: (null){ null }
          }) }
      }
      t2: (struct){ |((struct){
          #SpecFoo: (#struct){
            foo: (#struct){
            }
          }
          #SpecBar: (#struct){
            bar: (#struct){
              x: (int){ 1 }
            }
          }
          spec: (#struct){
            bar: (#struct){
              x: (int){ 1 }
            }
          }
          BAZ: (int){ 1 }
          f1: (int){ int }
          f2: (int){ int }
        }, (struct){
          #SpecFoo: (#struct){
            foo: (#struct){
            }
          }
          #SpecBar: (#struct){
            bar: (#struct){
              x: (int){ 1 }
            }
          }
          spec: (#struct){
            bar: (#struct){
              x: (int){ 1 }
            }
          }
          BAZ: (int){ 1 }
          f1: (int){ int }
          b2: (int){ int }
        }, (struct){
          #SpecFoo: (#struct){
            foo: (#struct){
            }
          }
          #SpecBar: (#struct){
            bar: (#struct){
              x: (int){ 1 }
            }
          }
          spec: (#struct){
            bar: (#struct){
              x: (int){ 1 }
            }
          }
          BAZ: (int){ 1 }
          b2: (int){ int }
          f2: (int){ int }
        }, (struct){
          #SpecFoo: (#struct){
            foo: (#struct){
            }
          }
          #SpecBar: (#struct){
            bar: (#struct){
              x: (int){ 1 }
            }
          }
          spec: (#struct){
            bar: (#struct){
              x: (int){ 1 }
            }
          }
          BAZ: (int){ 1 }
          b2: (int){ int }
        }) }
      t3: (struct){ |((struct){
          #A: (#struct){
            v: (int){ 1 }
          }
          BAZ: (int){ 1 }
          S: (#struct){
            x: (int){ 1 }
            y: (int){ 1 }
          }
          #B: (#struct){
            x: (int){ 1 }
            y: (int){ 1 }
          }
          f1: (int){ int }
          f2: (int){ int }
        }, (struct){
          #A: (#struct){
            v: (int){ 1 }
          }
          BAZ: (int){ 1 }
          S: (#struct){
            x: (int){ 1 }
            y: (int){ 1 }
          }
          #B: (#struct){
            x: (int){ 1 }
            y: (int){ 1 }
          }
          f1: (int){ int }
          b2: (int){ int }
        }, (struct){
          #A: (#struct){
            v: (int){ 1 }
          }
          BAZ: (int){ 1 }
          S: (#struct){
            x: (int){ 1 }
            y: (int){ 1 }
          }
          #B: (#struct){
            x: (int){ 1 }
            y: (int){ 1 }
          }
          b2: (int){ int }
          f2: (int){ int }
        }, (struct){
          #A: (#struct){
            v: (int){ 1 }
          }
          BAZ: (int){ 1 }
          S: (#struct){
            x: (int){ 1 }
            y: (int){ 1 }
          }
          #B: (#struct){
            x: (int){ 1 }
            y: (int){ 1 }
          }
          b2: (int){ int }
        }) }
    }
    full: (struct){
      Foo: (#struct){
        spec: (#struct){
          foo: (#struct){
            min: (int){ |(*(int){ 10 }, (int){ int }) }
            max: (int){ |(*(int){ 20 }, (int){ int }) }
          }
        }
        resource: (#struct){
          _X: (#struct){
            spec: ~(issue2209.full.Foo.spec)
          }
          spec: (#struct){ |(*(#struct){
              minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
              maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
              minBar?: (null){ null }
              maxBar?: (null){ null }
              hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
              fuga?: (null){ null }
            }, (#struct){
              minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
              maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
              minBar?: (null){ null }
              maxBar?: (null){ null }
              hoge?: (null){ null }
              fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
            }) }
        }
      }
      Bar: (#struct){
        spec: (#struct){
          bar: (#struct){
            min: (int){ |(*(int){ 30 }, (int){ int }) }
            max: (int){ |(*(int){ 40 }, (int){ int }) }
          }
        }
        resource: (#struct){
          _X: (#struct){
            spec: ~(issue2209.full.Bar.spec)
          }
          spec: (#struct){ |(*(#struct){
              minFoo?: (null){ null }
              maxFoo?: (null){ null }
              minBar: (int){ |(*(int){ 30 }, (int){ int }) }
              maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
              hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
              fuga?: (null){ null }
            }, (#struct){
              minFoo?: (null){ null }
              maxFoo?: (null){ null }
              minBar: (int){ |(*(int){ 30 }, (int){ int }) }
              maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
              hoge?: (null){ null }
              fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
            }) }
        }
      }
      #Abstract: (#struct){
        spec: (#struct){ |(*(#struct){
            foo: (#struct){
              min: (int){ |(*(int){ 10 }, (int){ int }) }
              max: (int){ |(*(int){ 20 }, (int){ int }) }
            }
          }, (#struct){
            bar: (#struct){
              min: (int){ |(*(int){ 30 }, (int){ int }) }
              max: (int){ |(*(int){ 40 }, (int){ int }) }
            }
          }) }
        resource: (#struct){
          _X: (#struct){
            spec: (#struct){ |(*(#struct){
                foo: (#struct){
                  min: (int){ |(*(int){ 10 }, (int){ int }) }
                  max: (int){ |(*(int){ 20 }, (int){ int }) }
                }
              }, (#struct){
                bar: (#struct){
                  min: (int){ |(*(int){ 30 }, (int){ int }) }
                  max: (int){ |(*(int){ 40 }, (int){ int }) }
                }
              }) }
          }
          spec: (#struct){ |(*(#struct){
              minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
              maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
              minBar?: (null){ null }
              maxBar?: (null){ null }
              hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
              fuga?: (null){ null }
            }, (#struct){
              minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
              maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
              minBar?: (null){ null }
              maxBar?: (null){ null }
              hoge?: (null){ null }
              fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
            }) }
        }
      }
      _#Spec: (#struct){ |(*(#struct){
          foo: (#struct){
            min: (int){ |(*(int){ 10 }, (int){ int }) }
            max: (int){ |(*(int){ 20 }, (int){ int }) }
          }
        }, (#struct){
          bar: (#struct){
            min: (int){ |(*(int){ 30 }, (int){ int }) }
            max: (int){ |(*(int){ 40 }, (int){ int }) }
          }
        }) }
      _#SpecFoo: (#struct){
        foo: (#struct){
          min: (int){ |(*(int){ 10 }, (int){ int }) }
          max: (int){ |(*(int){ 20 }, (int){ int }) }
        }
      }
      _#SpecBar: (#struct){
        bar: (#struct){
          min: (int){ |(*(int){ 30 }, (int){ int }) }
          max: (int){ |(*(int){ 40 }, (int){ int }) }
        }
      }
      _Thing: (#struct){
        _X: (_){ _ }
        spec: (#struct){ |(*(#struct){
            minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
            maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
            minBar?: (null){ null }
            maxBar?: (null){ null }
            hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
            fuga?: (null){ null }
          }, *(#struct){
            minFoo?: (null){ null }
            maxFoo?: (null){ null }
            minBar: (int){ |(*(int){ 30 }, (int){ int }) }
            maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
            hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
            fuga?: (null){ null }
          }, (#struct){
            minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
            maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
            minBar?: (null){ null }
            maxBar?: (null){ null }
            hoge?: (null){ null }
            fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
          }, (#struct){
            minFoo?: (null){ null }
            maxFoo?: (null){ null }
            minBar: (int){ |(*(int){ 30 }, (int){ int }) }
            maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
            hoge?: (null){ null }
            fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
          }) }
      }
      #Constrained: (#struct){
        spec: (#struct){ |(*(#struct){
            minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
            maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
            minBar?: (null){ null }
            maxBar?: (null){ null }
            hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
            fuga?: (null){ null }
          }, *(#struct){
            minFoo?: (null){ null }
            maxFoo?: (null){ null }
            minBar: (int){ |(*(int){ 30 }, (int){ int }) }
            maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
            hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
            fuga?: (null){ null }
          }, (#struct){
            minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
            maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
            minBar?: (null){ null }
            maxBar?: (null){ null }
            hoge?: (null){ null }
            fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
          }, (#struct){
            minFoo?: (null){ null }
            maxFoo?: (null){ null }
            minBar: (int){ |(*(int){ 30 }, (int){ int }) }
            maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
            hoge?: (null){ null }
            fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
          }) }
      }
      #Base: (#struct){
        spec: (#struct){
          minFoo?: ((null|int)){ |((null){ null }, (int){ int }) }
          maxFoo?: ((null|int)){ |((null){ null }, (int){ int }) }
          minBar?: ((null|int)){ |((null){ null }, (int){ int }) }
          maxBar?: ((null|int)){ |((null){ null }, (int){ int }) }
          hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
          fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
        }
      }
    }
  }
  issue2246: (struct){
    simplified: (struct){
      #FormFoo: (#struct){
        fooID: (string){ string }
      }
      #FormBar: (#struct){
        barID: (string){ string }
      }
      #Form: (#struct){ |((#struct){
          fooID: (string){ string }
        }, (#struct){
          barID: (string){ string }
        }) }
      data: (struct){
        fooID: (string){ "123" }
      }
      out1: (#struct){
        fooID: (string){ "123" }
      }
      out2: (#struct){
        fooID: (string){ "123" }
      }
    }
    full: (struct){
      data: (struct){
        forms: (#list){
          0: (struct){
            fooID: (string){ "00-0000001" }
          }
        }
      }
      form1040: (#list){
        0: (int){ 3 }
      }
      #K1: (#struct){
        #_base: (#struct){
          common: (int){ 3 }
        }
        #FormFoo: (#struct){
          fooID: (string){ string }
          common: (int){ 3 }
        }
        #FormBar: (#struct){
          barID: (string){ string }
          common: (int){ 3 }
        }
        #Form: (#struct){ |((#struct){
            fooID: (string){ string }
            common: (int){ 3 }
          }, (#struct){
            barID: (string){ string }
            common: (int){ 3 }
          }) }
      }
      #Input: (#struct){
        forms: (list){
        }
      }
      #summarizeReturn: (#struct){
        in: ~(issue2246.full.#Input)
        out: (#list){
        }
      }
      #compute: (#struct){
        in: ~(issue2246.full.#Input)
        out: (#list){
        }
      }
    }
  }
  issue2263: (struct){
    simplified: (struct){
      metrics: (#struct){
        id: (string){ "foo" }
        avg: (int){ 60 }
      }
      #Metric: (#struct){ |((#struct){
          id: (string){ string }
          avg: (number){ number }
        }, (#struct){
          id: (string){ string }
        }, (#struct){
          avg: (number){ number }
        }, (#struct){
        }) }
      #IDSource: (#struct){
        id: (string){ string }
      }
      #TargetAverage: (#struct){
        avg: (number){ number }
      }
    }
    full: (struct){
      metrics: (#list){
        0: (#struct){
          id: (string){ "foo" }
          avg: (int){ 60 }
        }
        1: (#struct){
          id: (string){ "bar" }
          value: (int){ 80 }
        }
        2: (#struct){
          uri: (string){ "baz" }
          avg: (int){ 70 }
        }
        3: (#struct){
          uri: (string){ "qux" }
          value: (int){ 90 }
        }
      }
      #Metric: (#struct){ |((#struct){
          id: (string){ string }
          avg: (number){ number }
        }, (#struct){
          id: (string){ string }
          value: (number){ number }
        }, (#struct){
          uri: (string){ string }
          avg: (number){ number }
        }, (#struct){
          uri: (string){ string }
          value: (number){ number }
        }) }
      #Source: (#struct){ |((#struct){
          id: (string){ string }
        }, (#struct){
          uri: (string){ string }
        }) }
      #Target: (#struct){ |((#struct){
          avg: (number){ number }
        }, (#struct){
          value: (number){ number }
        }) }
      #IDSource: (#struct){
        id: (string){ string }
      }
      #URISource: (#struct){
        uri: (string){ string }
      }
      #TargetAverage: (#struct){
        avg: (number){ number }
      }
      #TargetValue: (#struct){
        value: (number){ number }
      }
    }
  }
  issue3149: (struct){
    #valid: (#struct){
      name!: (string){ |((string){ &(=~"^Foo", =~"Foo$") }, (string){ "an exception" }) }
    }
    list: (#list){
      0: (#struct){
        name: (string){ "FooBarFoo" }
      }
      1: (#struct){
        name: (string){ "FooBazFoo" }
      }
      2: (#struct){
        name: (string){ "FooQuuxFoo" }
      }
      3: (#struct){
        name: (string){ "an exception" }
      }
    }
  }
  issue3528: (struct){
    original: (struct){
      workflows: (#list){
        0: (#struct){
          container: (#struct){
          }
          #container: ((string|struct)){ |((string){ string }, (#struct){
              volumes?: (list){
              }
            }) }
        }
      }
      test: (#struct){
        container: (#struct){
        }
        #container: ((string|struct)){ |((string){ string }, (#struct){
            volumes?: (list){
            }
          }) }
      }
      #Workflow: (#struct){
        container: (#struct){
        }
        #container: ((string|struct)){ |((string){ string }, (#struct){
            volumes?: (list){
            }
          }) }
      }
    }
    reduced: (struct){
      a: (#struct){
        A: (#struct){
        }
        #a: ((int|struct)){ |((int){ 2 }, (#struct){
            v: (int){ 1 }
          }) }
      }
      #A: (#struct){
        A: (#struct){
        }
        #a: ((int|struct)){ |((int){ 2 }, (#struct){
            v: (int){ 1 }
          }) }
      }
    }
    counter: (struct){
    }
    nested: (struct){
      t1: ((int|struct)){ |((struct){
          v: (int){ 1 }
        }, (int){ 2 }, (int){ 3 }) }
      t2: ((int|struct)){ |((struct){
          v: (int){ 1 }
        }, (int){ 2 }) }
    }
  }
  issue3784: (struct){
    reduced: (struct){
      #Schema: (#struct){
        a: (#struct){ |((#struct){
            kind: (string){ "A" }
            b: (#struct){
              c?: (string){ string }
            }
          }, (#struct){
            kind: (string){ "B" }
          }) }
      }
      out: (#struct){
        a: (#struct){
          kind: (string){ "A" }
          b: (#struct){
            c: (string){ "x" }
          }
        }
      }
    }
    full: (struct){
      #Schema: (#struct){
        pages?: (#struct){ |((#struct){
            build_type!: (string){ "legacy" }
            source!: (#struct){
              branch!: (string){ string }
              path?: (string){ string }
            }
            cname?: (string){ string }
          }, (#struct){
            build_type!: (string){ "workflow" }
            source?: (_|_){
              // [eval] issue3784.full.#Schema.pages.source: field not allowed:
              //     ./issue3784.cue:20:4
              branch?: (string){ string }
              path?: (string){ string }
            }
            cname?: (string){ string }
          }) }
      }
      out: (#struct){
        pages: (#struct){
          cname: (string){ "foo.com" }
          build_type: (string){ "legacy" }
          source: (#struct){
            branch: (string){ "main" }
            path: (string){ "/" }
          }
        }
      }
    }
    variant1: (struct){
      #Schema: (#struct){
        pages: (#struct){
          build_type!: (string){ "legacy" }
          source: (#struct){
            branch!: (string){ string }
            path?: (string){ string }
          }
          cname?: (string){ string }
        }
      }
    }
    variant2: (struct){
      #Schema: (#struct){ |((#struct){
          build_type!: (string){ "legacy" }
          source!: (#struct){
            branch!: (_){ _ }
          }
        }, (#struct){
          build_type!: (string){ "workflow" }
          cname?: (_){ _ }
        }) }
      a: (#struct){
        build_type!: (string){ "legacy" }
        source: (#struct){
          branch!: (string){ string }
          path?: (_|_){
            // [eval] issue3784.variant2.a.source.path: field not allowed:
            //     ./issue3784.cue:83:4
          }
        }
        cname?: (_|_){
          // [eval] issue3784.variant2.a.cname: field not allowed:
          //     ./issue3784.cue:85:3
        }
      }
    }
  }
  issue3958: (struct){
    t1: (struct){
      #schema: (int){ |((int){ int }, (int){ 3 }, (int){ 1 }) }
      test1: (int){ |((int){ int }, (int){ 3 }, (int){ 1 }, (int){ 2 }) }
      test2: (int){ |((int){ int }, (int){ 3 }, (int){ 1 }, (int){ 4 }) }
    }
    t2: (struct){
      a: (int){ |((int){ int }, (int){ 8 }, (int){ 3 }, (int){ 1 }, (int){ 4 }) }
      b: (int){ |((int){ int }, (int){ 3 }, (int){ 1 }, (int){ 4 }) }
    }
  }
  issue770: (struct){
    #A: (#struct){
      v: (string){ |((string){ "a" }, (string){ "b" }, (string){ "c" }) }
    }
    h: (struct){
      a: (#struct){
        v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) }
      }
      b: (#struct){
        v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) }
      }
      boo: (#struct){
        v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) }
      }
      c: (#struct){
        v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) }
      }
      coo: (#struct){
        v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) }
      }
    }
  }
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -1,58 +1,4 @@
-Errors:
-issue1417.ids.2: 2 errors in empty disjunction:
-issue2209.full.Bar.resource.spec: 6 errors in empty disjunction:
-issue2209.full.Bar.resource.spec.minBar: 2 errors in empty disjunction:
-issue2209.full.Bar.resource.spec.minBar: conflicting values null and int (mismatched types null and int):
-    ./issue2209full.cue:43:7
-    ./issue2209full.cue:48:13
-    ./issue2209full.cue:67:10
-    ./issue2209full.cue:83:16
-    ./issue2209full.cue:87:13
-    ./issue2209full.cue:107:20
-issue2209.full.Bar.resource.spec.minFoo: 2 errors in empty disjunction:
-issue2209.full.Bar.resource.spec.minFoo: conflicting values null and 10 (mismatched types null and int):
-    ./issue2209full.cue:43:7
-    ./issue2209full.cue:48:13
-    ./issue2209full.cue:55:16
-    ./issue2209full.cue:71:4
-    ./issue2209full.cue:72:13
-    ./issue2209full.cue:92:13
-issue2209.full.Bar.resource.spec.minFoo: conflicting values null and int (mismatched types null and int):
-    ./issue2209full.cue:43:7
-    ./issue2209full.cue:48:13
-    ./issue2209full.cue:67:10
-    ./issue2209full.cue:83:16
-    ./issue2209full.cue:92:13
-    ./issue2209full.cue:105:20
-issue3149.list.3.name: 2 errors in empty disjunction:
-issue1417.ids.1: invalid value "ab" (out of bound !~"^a"):
-    ./issue1417.cue:2:7
-    ./issue1417.cue:4:11
-    ./issue1417.cue:4:26
-issue1417.ids.2: invalid value "aB" (out of bound !~"^a"):
-    ./issue1417.cue:2:7
-    ./issue1417.cue:4:11
-    ./issue1417.cue:4:32
-issue1417.ids.2: invalid value "aB" (out of bound !~"[A-Z]"):
-    ./issue1417.cue:3:16
-    ./issue1417.cue:4:11
-    ./issue1417.cue:4:32
-issue2209.simplified.t3.BAZ: undefined field: y:
-    ./issue2209full.cue:35:9
-issue2209.full.Bar.resource.spec.minBar: undefined field: min:
-    ./issue2209full.cue:77:25
-issue3149.list.3.name: invalid value "an exception" (out of bound =~"^Foo"):
-    ./issue3149.cue:3:13
-    ./issue3149.cue:3:10
-    ./issue3149.cue:10:10
-issue3149.list.3.name: invalid value "an exception" (out of bound =~"Foo$"):
-    ./issue3149.cue:3:46
-    ./issue3149.cue:3:10
-    ./issue3149.cue:10:10
-
-Result:
-(_|_){
-  // [eval]
+(struct){
   disambiguateClosed: (struct){
     b: (#struct){ |((#struct){
         x: (bool){ true }
@@ -181,7 +127,7 @@
             x: ((null|struct)){ |((struct){
                 a: (struct){
                   b: (_|_){
-                    // [incomplete] nestedNonMonotonic.incomplete.b.n2.p1.x.a.b: invalid value {c:1 & 1 & 1,d:1 & 1 & 1} (does not satisfy struct.MinFields(3)): len(fields) < MinFields(3) (2 < 3):
+                    // [incomplete] nestedNonMonotonic.incomplete.b.n2.p1.x.a.b: invalid value {c:1,d:1} (does not satisfy struct.MinFields(3)): len(fields) < MinFields(3) (2 < 3):
                     //     ./in.cue:138:15
                     //     ./in.cue:124:15
                     //     ./in.cue:125:12
@@ -349,10 +295,6 @@
       #type: (#struct){
         fieldName: ((string|struct)){ |((string){ string }, (#struct){
             foo: (string){ string }
-          }, (#struct){
-            bar: ((string|struct)){ |((string){ string }, (#struct){
-                foo: (string){ string }
-              }) }
           }) }
       }
       #subtype: ((string|struct)){ |((string){ string }, (#struct){
@@ -432,12 +374,8 @@
     #T: (list){
       0: (string){ "d" }
     }
-    x: (list){
-      0: (string){ "d" }
-    }
-    #X: (list){
-      0: (string){ "d" }
-    }
+    x: ~(noHang.#T)
+    #X: ~(noHang.#T)
   }
   issue1940: (struct){
     #T: (#list){
@@ -446,53 +384,24 @@
       }
     }
     #A: (#struct){
-      type: (#list){
-        0: (string){ "d" }
-        1: (list){
-        }
-      }
+      type: ~(issue1940.#T)
     }
     #B: (#struct){
     }
     #C: (#struct){
-      x: (#struct){
-        type: (#list){
-          0: (string){ "d" }
-          1: (list){
-          }
-        }
-      }
-    }
-  }
-  issue1417: (_|_){
-    // [eval]
+      x: ~(issue1940.#A)
+    }
+  }
+  issue1417: (struct){
     #ID: (string){ |((string){ &(!~"^a", =~"^a") }, (string){ &(!~"^a", !~"[A-Z]") }, (string){ &(=~"^ab$", =~"^a") }, (string){ &(=~"^ab$", !~"[A-Z]") }, (string){ &(=~"^aB$", =~"^a") }, (string){ &(=~"^aB$", !~"[A-Z]") }) }
-    ids: (_|_){
-      // [eval]
+    ids: (#list){
       0: (string){ "xyz" }
-      1: (_|_){
-        // [eval] issue1417.ids.1: invalid value "ab" (out of bound !~"^a"):
-        //     ./issue1417.cue:2:7
-        //     ./issue1417.cue:4:11
-        //     ./issue1417.cue:4:26
-      }
-      2: (_|_){
-        // [eval] issue1417.ids.2: 2 errors in empty disjunction:
-        // issue1417.ids.2: invalid value "aB" (out of bound !~"^a"):
-        //     ./issue1417.cue:2:7
-        //     ./issue1417.cue:4:11
-        //     ./issue1417.cue:4:32
-        // issue1417.ids.2: invalid value "aB" (out of bound !~"[A-Z]"):
-        //     ./issue1417.cue:3:16
-        //     ./issue1417.cue:4:11
-        //     ./issue1417.cue:4:32
-      }
-    }
-  }
-  issue2209: (_|_){
-    // [eval]
-    simplified: (_|_){
-      // [eval]
+      1: (string){ "ab" }
+      2: (string){ "aB" }
+    }
+  }
+  issue2209: (struct){
+    simplified: (struct){
       t1: (struct){
         #SpecFoo: (#struct){
           foo: (#struct){
@@ -510,93 +419,159 @@
           }
         }
         out: (struct){ |((struct){
-            X: (#struct){
-              bar: (#struct){
-                min: (int){ 1 }
-              }
-            }
-            nullFoo: (null){ null }
-            minFoo: (int){ int }
-          }, (struct){
-            minBar: (int){ int }
-            X: (#struct){
-              bar: (#struct){
-                min: (int){ 1 }
-              }
-            }
-            nullFoo: (null){ null }
-          }, (struct){
-            X: (#struct){
-              bar: (#struct){
-                min: (int){ 1 }
-              }
-            }
-            nullBar: (null){ null }
-            minFoo: (int){ int }
-          }, (struct){
-            minBar: (int){ int }
-            X: (#struct){
-              bar: (#struct){
-                min: (int){ 1 }
-              }
-            }
-            nullBar: (null){ null }
-          }) }
-      }
-      t2: (_|_){
-        // [incomplete] issue2209.simplified.t2.BAZ: undefined field: x:
-        //     ./issue2209full.cue:24:17
-        #SpecFoo: (#struct){
-          foo: (#struct){
-          }
-        }
-        #SpecBar: (#struct){
-          bar: (#struct){
-            x: (int){ 1 }
-          }
-        }
-        spec: (#struct){ |(*(#struct){
-            bar: (struct){
-            }
-            foo: (#struct){
-            }
-          }, (#struct){
-            bar: (#struct){
-              x: (int){ 1 }
-            }
-          }) }
-        BAZ: (_|_){
-          // [incomplete] issue2209.simplified.t2.BAZ: undefined field: x:
-          //     ./issue2209full.cue:24:17
-        }
-        b2: (int){ int }
-      }
-      t3: (_|_){
-        // [eval] issue2209.simplified.t3.BAZ: undefined field: y:
-        //     ./issue2209full.cue:35:9
-        #A: (#struct){
-          v: (int){ 1 }
-        }
-        BAZ: (_|_){
-          // [eval] issue2209.simplified.t3.BAZ: undefined field: y:
-          //     ./issue2209full.cue:35:9
-        }
-        S: (#struct){ |(*(#struct){
-            x: (int){ 1 }
-            v: (int){ 1 }
-          }, (#struct){
-            x: (int){ 1 }
-            y: (int){ 1 }
-          }) }
-        #B: (#struct){
-          x: (int){ 1 }
-          y: (int){ 1 }
-        }
-        b2: (int){ int }
-      }
-    }
-    full: (_|_){
-      // [eval]
+            minBar: (int){ 1 }
+            X: ~(issue2209.simplified.t1.spec)
+            nullFoo: (null){ null }
+            minFoo: (int){ int }
+          }, (struct){
+            minBar: (int){ 1 }
+            X: ~(issue2209.simplified.t1.spec)
+            nullFoo: (null){ null }
+          }, (struct){
+            minBar: (int){ 1 }
+            X: ~(issue2209.simplified.t1.spec)
+            nullBar: (null){ null }
+            minFoo: (int){ int }
+          }, (struct){
+            minBar: (int){ 1 }
+            X: ~(issue2209.simplified.t1.spec)
+            nullBar: (null){ null }
+          }) }
+      }
+      t2: (struct){ |((struct){
+          #SpecFoo: (#struct){
+            foo: (#struct){
+            }
+          }
+          #SpecBar: (#struct){
+            bar: (#struct){
+              x: (int){ 1 }
+            }
+          }
+          spec: (#struct){
+            bar: (#struct){
+              x: (int){ 1 }
+            }
+          }
+          BAZ: (int){ 1 }
+          f1: (int){ int }
+          f2: (int){ int }
+        }, (struct){
+          #SpecFoo: (#struct){
+            foo: (#struct){
+            }
+          }
+          #SpecBar: (#struct){
+            bar: (#struct){
+              x: (int){ 1 }
+            }
+          }
+          spec: (#struct){
+            bar: (#struct){
+              x: (int){ 1 }
+            }
+          }
+          BAZ: (int){ 1 }
+          f1: (int){ int }
+          b2: (int){ int }
+        }, (struct){
+          #SpecFoo: (#struct){
+            foo: (#struct){
+            }
+          }
+          #SpecBar: (#struct){
+            bar: (#struct){
+              x: (int){ 1 }
+            }
+          }
+          spec: (#struct){
+            bar: (#struct){
+              x: (int){ 1 }
+            }
+          }
+          BAZ: (int){ 1 }
+          b2: (int){ int }
+          f2: (int){ int }
+        }, (struct){
+          #SpecFoo: (#struct){
+            foo: (#struct){
+            }
+          }
+          #SpecBar: (#struct){
+            bar: (#struct){
+              x: (int){ 1 }
+            }
+          }
+          spec: (#struct){
+            bar: (#struct){
+              x: (int){ 1 }
+            }
+          }
+          BAZ: (int){ 1 }
+          b2: (int){ int }
+        }) }
+      t3: (struct){ |((struct){
+          #A: (#struct){
+            v: (int){ 1 }
+          }
+          BAZ: (int){ 1 }
+          S: (#struct){
+            x: (int){ 1 }
+            y: (int){ 1 }
+          }
+          #B: (#struct){
+            x: (int){ 1 }
+            y: (int){ 1 }
+          }
+          f1: (int){ int }
+          f2: (int){ int }
+        }, (struct){
+          #A: (#struct){
+            v: (int){ 1 }
+          }
+          BAZ: (int){ 1 }
+          S: (#struct){
+            x: (int){ 1 }
+            y: (int){ 1 }
+          }
+          #B: (#struct){
+            x: (int){ 1 }
+            y: (int){ 1 }
+          }
+          f1: (int){ int }
+          b2: (int){ int }
+        }, (struct){
+          #A: (#struct){
+            v: (int){ 1 }
+          }
+          BAZ: (int){ 1 }
+          S: (#struct){
+            x: (int){ 1 }
+            y: (int){ 1 }
+          }
+          #B: (#struct){
+            x: (int){ 1 }
+            y: (int){ 1 }
+          }
+          b2: (int){ int }
+          f2: (int){ int }
+        }, (struct){
+          #A: (#struct){
+            v: (int){ 1 }
+          }
+          BAZ: (int){ 1 }
+          S: (#struct){
+            x: (int){ 1 }
+            y: (int){ 1 }
+          }
+          #B: (#struct){
+            x: (int){ 1 }
+            y: (int){ 1 }
+          }
+          b2: (int){ int }
+        }) }
+    }
+    full: (struct){
       Foo: (#struct){
         spec: (#struct){
           foo: (#struct){
@@ -605,135 +580,52 @@
           }
         }
         resource: (#struct){
-          spec: (#struct){ |(*(#struct){
-              minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
-              maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
-              minBar?: (null){ null }
-              maxBar?: (null){ null }
-              hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
-              fuga?: (null){ null }
-            }, (#struct){
-              minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
-              maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
-              minBar?: (null){ null }
-              maxBar?: (null){ null }
-              hoge?: (null){ null }
-              fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
-            }) }
-          _X: (#struct){
-            spec: (#struct){ |(*(#struct){
-                foo: (#struct){
-                  min: (int){ |(*(int){ 10 }, (int){ int }) }
-                  max: (int){ |(*(int){ 20 }, (int){ int }) }
-                }
-              }, (#struct){
-                foo: (#struct){
-                }
-                bar: (#struct){
-                  min: (int){ |(*(int){ 30 }, (int){ int }) }
-                  max: (int){ |(*(int){ 40 }, (int){ int }) }
-                }
-              }) }
-          }
-        }
-      }
-      Bar: (_|_){
-        // [eval]
-        spec: (#struct){
-          bar: (#struct){
-            min: (int){ |(*(int){ 30 }, (int){ int }) }
-            max: (int){ |(*(int){ 40 }, (int){ int }) }
-          }
-        }
-        resource: (_|_){
-          // [eval]
-          spec: (_|_){
-            // [eval] issue2209.full.Bar.resource.spec: 6 errors in empty disjunction:
-            // issue2209.full.Bar.resource.spec.minBar: 2 errors in empty disjunction:
-            // issue2209.full.Bar.resource.spec.minBar: conflicting values null and int (mismatched types null and int):
-            //     ./issue2209full.cue:43:7
-            //     ./issue2209full.cue:48:13
-            //     ./issue2209full.cue:67:10
-            //     ./issue2209full.cue:83:16
-            //     ./issue2209full.cue:87:13
-            //     ./issue2209full.cue:107:20
-            // issue2209.full.Bar.resource.spec.minFoo: 2 errors in empty disjunction:
-            // issue2209.full.Bar.resource.spec.minFoo: conflicting values null and 10 (mismatched types null and int):
-            //     ./issue2209full.cue:43:7
-            //     ./issue2209full.cue:48:13
-            //     ./issue2209full.cue:55:16
-            //     ./issue2209full.cue:71:4
-            //     ./issue2209full.cue:72:13
-            //     ./issue2209full.cue:92:13
-            // issue2209.full.Bar.resource.spec.minFoo: conflicting values null and int (mismatched types null and int):
-            //     ./issue2209full.cue:43:7
-            //     ./issue2209full.cue:48:13
-            //     ./issue2209full.cue:67:10
-            //     ./issue2209full.cue:83:16
-            //     ./issue2209full.cue:92:13
-            //     ./issue2209full.cue:105:20
-            // issue2209.full.Bar.resource.spec.minBar: undefined field: min:
-            //     ./issue2209full.cue:77:25
-            minFoo: (_|_){
-              // [eval] issue2209.full.Bar.resource.spec.minFoo: 2 errors in empty disjunction:
-              // issue2209.full.Bar.resource.spec.minFoo: conflicting values null and 10 (mismatched types null and int):
-              //     ./issue2209full.cue:43:7
-              //     ./issue2209full.cue:48:13
-              //     ./issue2209full.cue:55:16
-              //     ./issue2209full.cue:71:4
-              //     ./issue2209full.cue:72:13
-              //     ./issue2209full.cue:92:13
-              // issue2209.full.Bar.resource.spec.minFoo: conflicting values null and int (mismatched types null and int):
-              //     ./issue2209full.cue:43:7
-              //     ./issue2209full.cue:48:13
-              //     ./issue2209full.cue:67:10
-              //     ./issue2209full.cue:83:16
-              //     ./issue2209full.cue:92:13
-              //     ./issue2209full.cue:105:20
-            }
-            maxFoo: (_|_){
-              // [eval] issue2209.full.Bar.resource.spec.maxFoo: 2 errors in empty disjunction:
-              // issue2209.full.Bar.resource.spec.maxFoo: conflicting values null and 20 (mismatched types null and int):
-              //     ./issue2209full.cue:43:7
-              //     ./issue2209full.cue:48:13
-              //     ./issue2209full.cue:56:16
-              //     ./issue2209full.cue:71:4
-              //     ./issue2209full.cue:73:13
-              //     ./issue2209full.cue:93:13
-              // issue2209.full.Bar.resource.spec.maxFoo: conflicting values null and int (mismatched types null and int):
-              //     ./issue2209full.cue:43:7
-              //     ./issue2209full.cue:48:13
-              //     ./issue2209full.cue:67:10
-              //     ./issue2209full.cue:83:16
-              //     ./issue2209full.cue:93:13
-              //     ./issue2209full.cue:106:20
-            }
-            minBar: (_|_){
-              // [eval] issue2209.full.Bar.resource.spec.minBar: undefined field: min:
-              //     ./issue2209full.cue:77:25
-            }
-            maxBar: (_|_){
-              // [eval] issue2209.full.Bar.resource.spec.maxBar: undefined field: max:
-              //     ./issue2209full.cue:78:25
-            }
-            hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
-            fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
-          }
-          _X: (#struct){
-            spec: (#struct){ |(*(#struct){
-                bar: (#struct){
-                }
-                foo: (#struct){
-                  min: (int){ |(*(int){ 10 }, (int){ int }) }
-                  max: (int){ |(*(int){ 20 }, (int){ int }) }
-                }
-              }, (#struct){
-                bar: (#struct){
-                  min: (int){ |(*(int){ 30 }, (int){ int }) }
-                  max: (int){ |(*(int){ 40 }, (int){ int }) }
-                }
-              }) }
-          }
+          _X: (#struct){
+            spec: ~(issue2209.full.Foo.spec)
+          }
+          spec: (#struct){ |(*(#struct){
+              minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
+              maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
+              minBar?: (null){ null }
+              maxBar?: (null){ null }
+              hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
+              fuga?: (null){ null }
+            }, (#struct){
+              minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
+              maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
+              minBar?: (null){ null }
+              maxBar?: (null){ null }
+              hoge?: (null){ null }
+              fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
+            }) }
+        }
+      }
+      Bar: (#struct){
+        spec: (#struct){
+          bar: (#struct){
+            min: (int){ |(*(int){ 30 }, (int){ int }) }
+            max: (int){ |(*(int){ 40 }, (int){ int }) }
+          }
+        }
+        resource: (#struct){
+          _X: (#struct){
+            spec: ~(issue2209.full.Bar.spec)
+          }
+          spec: (#struct){ |(*(#struct){
+              minFoo?: (null){ null }
+              maxFoo?: (null){ null }
+              minBar: (int){ |(*(int){ 30 }, (int){ int }) }
+              maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
+              hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
+              fuga?: (null){ null }
+            }, (#struct){
+              minFoo?: (null){ null }
+              maxFoo?: (null){ null }
+              minBar: (int){ |(*(int){ 30 }, (int){ int }) }
+              maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
+              hoge?: (null){ null }
+              fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
+            }) }
         }
       }
       #Abstract: (#struct){
@@ -749,34 +641,34 @@
             }
           }) }
         resource: (#struct){
-          spec: (#struct){ |(*(#struct){
-              minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
-              maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
-              minBar?: (null){ null }
-              maxBar?: (null){ null }
-              hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
-              fuga?: (null){ null }
-            }, (#struct){
-              minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
-              maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
-              minBar?: (null){ null }
-              maxBar?: (null){ null }
-              hoge?: (null){ null }
-              fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
-            }) }
-          _X: (#struct){
-            spec: (#struct){ |(*(#struct){
-                foo: (#struct){
-                  min: (int){ |(*(int){ 10 }, (int){ int }) }
-                  max: (int){ |(*(int){ 20 }, (int){ int }) }
-                }
-              }, (#struct){
-                bar: (#struct){
-                  min: (int){ |(*(int){ 30 }, (int){ int }) }
-                  max: (int){ |(*(int){ 40 }, (int){ int }) }
-                }
-              }) }
-          }
+          _X: (#struct){
+            spec: (#struct){ |(*(#struct){
+                foo: (#struct){
+                  min: (int){ |(*(int){ 10 }, (int){ int }) }
+                  max: (int){ |(*(int){ 20 }, (int){ int }) }
+                }
+              }, (#struct){
+                bar: (#struct){
+                  min: (int){ |(*(int){ 30 }, (int){ int }) }
+                  max: (int){ |(*(int){ 40 }, (int){ int }) }
+                }
+              }) }
+          }
+          spec: (#struct){ |(*(#struct){
+              minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
+              maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
+              minBar?: (null){ null }
+              maxBar?: (null){ null }
+              hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
+              fuga?: (null){ null }
+            }, (#struct){
+              minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
+              maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
+              minBar?: (null){ null }
+              maxBar?: (null){ null }
+              hoge?: (null){ null }
+              fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
+            }) }
         }
       }
       _#Spec: (#struct){ |(*(#struct){
@@ -803,36 +695,36 @@
         }
       }
       _Thing: (#struct){
-        spec: (#struct){ |(*(#struct){
-            minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
-            maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
-            minBar?: (null){ null }
-            maxBar?: (null){ null }
-            hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
-            fuga?: (null){ null }
-          }, *(#struct){
-            minFoo?: (null){ null }
-            maxFoo?: (null){ null }
-            minBar: (int){ |(*(int){ 30 }, (int){ int }) }
-            maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
-            hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
-            fuga?: (null){ null }
-          }, (#struct){
-            minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
-            maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
-            minBar?: (null){ null }
-            maxBar?: (null){ null }
-            hoge?: (null){ null }
-            fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
-          }, (#struct){
-            minFoo?: (null){ null }
-            maxFoo?: (null){ null }
-            minBar: (int){ |(*(int){ 30 }, (int){ int }) }
-            maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
-            hoge?: (null){ null }
-            fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
-          }) }
         _X: (_){ _ }
+        spec: (#struct){ |(*(#struct){
+            minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
+            maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
+            minBar?: (null){ null }
+            maxBar?: (null){ null }
+            hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
+            fuga?: (null){ null }
+          }, *(#struct){
+            minFoo?: (null){ null }
+            maxFoo?: (null){ null }
+            minBar: (int){ |(*(int){ 30 }, (int){ int }) }
+            maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
+            hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
+            fuga?: (null){ null }
+          }, (#struct){
+            minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
+            maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
+            minBar?: (null){ null }
+            maxBar?: (null){ null }
+            hoge?: (null){ null }
+            fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
+          }, (#struct){
+            minFoo?: (null){ null }
+            maxFoo?: (null){ null }
+            minBar: (int){ |(*(int){ 30 }, (int){ int }) }
+            maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
+            hoge?: (null){ null }
+            fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
+          }) }
       }
       #Constrained: (#struct){
         spec: (#struct){ |(*(#struct){
@@ -916,19 +808,19 @@
           common: (int){ 3 }
         }
         #FormFoo: (#struct){
-          common: (int){ 3 }
-          fooID: (string){ string }
+          fooID: (string){ string }
+          common: (int){ 3 }
         }
         #FormBar: (#struct){
-          common: (int){ 3 }
-          barID: (string){ string }
+          barID: (string){ string }
+          common: (int){ 3 }
         }
         #Form: (#struct){ |((#struct){
-            common: (int){ 3 }
             fooID: (string){ string }
-          }, (#struct){
-            common: (int){ 3 }
+            common: (int){ 3 }
+          }, (#struct){
             barID: (string){ string }
+            common: (int){ 3 }
           }) }
       }
       #Input: (#struct){
@@ -936,18 +828,12 @@
         }
       }
       #summarizeReturn: (#struct){
-        in: (#struct){
-          forms: (list){
-          }
-        }
+        in: ~(issue2246.full.#Input)
         out: (#list){
         }
       }
       #compute: (#struct){
-        in: (#struct){
-          forms: (list){
-          }
-        }
+        in: ~(issue2246.full.#Input)
         out: (#list){
         }
       }
@@ -1031,13 +917,11 @@
       }
     }
   }
-  issue3149: (_|_){
-    // [eval]
+  issue3149: (struct){
     #valid: (#struct){
       name!: (string){ |((string){ &(=~"^Foo", =~"Foo$") }, (string){ "an exception" }) }
     }
-    list: (_|_){
-      // [eval]
+    list: (#list){
       0: (#struct){
         name: (string){ "FooBarFoo" }
       }
@@ -1047,19 +931,8 @@
       2: (#struct){
         name: (string){ "FooQuuxFoo" }
       }
-      3: (_|_){
-        // [eval]
-        name: (_|_){
-          // [eval] issue3149.list.3.name: 2 errors in empty disjunction:
-          // issue3149.list.3.name: invalid value "an exception" (out of bound =~"^Foo"):
-          //     ./issue3149.cue:3:13
-          //     ./issue3149.cue:3:10
-          //     ./issue3149.cue:10:10
-          // issue3149.list.3.name: invalid value "an exception" (out of bound =~"Foo$"):
-          //     ./issue3149.cue:3:46
-          //     ./issue3149.cue:3:10
-          //     ./issue3149.cue:10:10
-        }
+      3: (#struct){
+        name: (string){ "an exception" }
       }
     }
   }
@@ -1151,7 +1024,9 @@
             cname?: (string){ string }
           }, (#struct){
             build_type!: (string){ "workflow" }
-            source?: (#struct){
+            source?: (_|_){
+              // [eval] issue3784.full.#Schema.pages.source: field not allowed:
+              //     ./issue3784.cue:20:4
               branch?: (string){ string }
               path?: (string){ string }
             }
@@ -1160,12 +1035,12 @@
       }
       out: (#struct){
         pages: (#struct){
+          cname: (string){ "foo.com" }
           build_type: (string){ "legacy" }
           source: (#struct){
             branch: (string){ "main" }
             path: (string){ "/" }
           }
-          cname: (string){ "foo.com" }
         }
       }
     }
@@ -1195,9 +1070,15 @@
         build_type!: (string){ "legacy" }
         source: (#struct){
           branch!: (string){ string }
-          path?: (string){ string }
-        }
-        cname?: (string){ string }
+          path?: (_|_){
+            // [eval] issue3784.variant2.a.source.path: field not allowed:
+            //     ./issue3784.cue:83:4
+          }
+        }
+        cname?: (_|_){
+          // [eval] issue3784.variant2.a.cname: field not allowed:
+          //     ./issue3784.cue:85:3
+        }
       }
     }
   }
@@ -1204,8 +1085,8 @@
   issue3958: (struct){
     t1: (struct){
       #schema: (int){ |((int){ int }, (int){ 3 }, (int){ 1 }) }
-      test1: (int){ |((int){ int }, (int){ 2 }, (int){ 3 }, (int){ 1 }) }
-      test2: (int){ |((int){ int }, (int){ 4 }, (int){ 3 }, (int){ 1 }) }
+      test1: (int){ |((int){ int }, (int){ 3 }, (int){ 1 }, (int){ 2 }) }
+      test2: (int){ |((int){ int }, (int){ 3 }, (int){ 1 }, (int){ 4 }) }
     }
     t2: (struct){
       a: (int){ |((int){ int }, (int){ 8 }, (int){ 3 }, (int){ 1 }, (int){ 4 }) }
@@ -1227,10 +1108,10 @@
         v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) }
       }
       c: (#struct){
-        v: (string){ |(*(string){ "a" }, *(string){ "b" }, *(string){ "c" }) }
+        v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) }
       }
       coo: (#struct){
-        v: (string){ |(*(string){ "a" }, *(string){ "b" }, *(string){ "c" }) }
+        v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) }
       }
     }
   }
-- out/evalalpha/stats --
Leaks:  2856
Freed:  0
Reused: 0
Allocs: 2856
Retain: 0

Unifications: 694
Conjuncts:    2853
Disjuncts:    1352

CloseIDElems: 6129
NumCloseIDs: 321
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
diff old new
--- old
+++ new
@@ -1,9 +1,12 @@
-Leaks:  9
-Freed:  2856
-Reused: 2841
-Allocs: 24
-Retain: 123
-
-Unifications: 1435
-Conjuncts:    4154
-Disjuncts:    2979
+Leaks:  2856
+Freed:  0
+Reused: 0
+Allocs: 2856
+Retain: 0
+
+Unifications: 694
+Conjuncts:    2853
+Disjuncts:    1352
+
+CloseIDElems: 6129
+NumCloseIDs: 321
-- out/eval/stats --
Leaks:  9
Freed:  2856
Reused: 2841
Allocs: 24
Retain: 123

Unifications: 1435
Conjuncts:    4154
Disjuncts:    2979
-- diff/todo/p2 --
noChildError.issue1808.#type: one disjunction options eliminated due to earlier detected structural cycle. May be okay, but investigate.
issue2209.simplified.full._X: ditto
-- diff/explanation --
issue2209.simplified.t2.BAZ: now fixed
issue2209.simplified.t3.BAZ: missing error.
issue2209.simplified.t3: new evaluator fixes known bug.
preserveClosedness.medium.p*: discarding of default is correct.
issue1417: new evaluator fixes known bug
issue3149: new evaluator fixes known bug
issue770: new evaluator fixes a bug in "c" and "coo" where defaults did not apply correctly.
-- out/eval --
Errors:
issue1417.ids.2: 2 errors in empty disjunction:
issue2209.full.Bar.resource.spec: 6 errors in empty disjunction:
issue2209.full.Bar.resource.spec.minBar: 2 errors in empty disjunction:
issue2209.full.Bar.resource.spec.minBar: conflicting values null and int (mismatched types null and int):
    ./issue2209full.cue:43:7
    ./issue2209full.cue:48:13
    ./issue2209full.cue:67:10
    ./issue2209full.cue:83:16
    ./issue2209full.cue:87:13
    ./issue2209full.cue:107:20
issue2209.full.Bar.resource.spec.minFoo: 2 errors in empty disjunction:
issue2209.full.Bar.resource.spec.minFoo: conflicting values null and 10 (mismatched types null and int):
    ./issue2209full.cue:43:7
    ./issue2209full.cue:48:13
    ./issue2209full.cue:55:16
    ./issue2209full.cue:71:4
    ./issue2209full.cue:72:13
    ./issue2209full.cue:92:13
issue2209.full.Bar.resource.spec.minFoo: conflicting values null and int (mismatched types null and int):
    ./issue2209full.cue:43:7
    ./issue2209full.cue:48:13
    ./issue2209full.cue:67:10
    ./issue2209full.cue:83:16
    ./issue2209full.cue:92:13
    ./issue2209full.cue:105:20
issue3149.list.3.name: 2 errors in empty disjunction:
issue1417.ids.1: invalid value "ab" (out of bound !~"^a"):
    ./issue1417.cue:2:7
    ./issue1417.cue:4:11
    ./issue1417.cue:4:26
issue1417.ids.2: invalid value "aB" (out of bound !~"^a"):
    ./issue1417.cue:2:7
    ./issue1417.cue:4:11
    ./issue1417.cue:4:32
issue1417.ids.2: invalid value "aB" (out of bound !~"[A-Z]"):
    ./issue1417.cue:3:16
    ./issue1417.cue:4:11
    ./issue1417.cue:4:32
issue2209.simplified.t3.BAZ: undefined field: y:
    ./issue2209full.cue:35:9
issue2209.full.Bar.resource.spec.minBar: undefined field: min:
    ./issue2209full.cue:77:25
issue3149.list.3.name: invalid value "an exception" (out of bound =~"^Foo"):
    ./issue3149.cue:3:13
    ./issue3149.cue:3:10
    ./issue3149.cue:10:10
issue3149.list.3.name: invalid value "an exception" (out of bound =~"Foo$"):
    ./issue3149.cue:3:46
    ./issue3149.cue:3:10
    ./issue3149.cue:10:10

Result:
(_|_){
  // [eval]
  disambiguateClosed: (struct){
    b: (#struct){ |((#struct){
        x: (bool){ true }
      }, (#struct){
        y: (bool){ true }
      }) }
    a: (#struct){ |((#struct){
        x: (bool){ true }
      }, (#struct){
        y: (bool){ true }
      }) }
    #Def: (#struct){ |((#struct){
        x: (bool){ true }
      }, (#struct){
        y: (bool){ true }
      }) }
  }
  alwaysCheckMatchers1: (struct){
    b: (struct){
      c: (string){ "yyyyy" }
    }
  }
  alwaysCheckPatterns2: (struct){
    a: (#struct){
      c: (string){ "yyyyy" }
    }
    b: (#struct){
      c: (string){ "yyyyy" }
    }
    #X: ((string|struct)){ |((string){ string }, (#struct){
        c: (string){ string }
      }) }
  }
  nestedNonMonotonic: (struct){
    resolved: (struct){
      n1: (struct){
        x: ((null|struct)){ |((struct){
            a: (struct){
              c: (int){ 1 }
              d: (int){ 1 }
            }
          }, (null){ null }) }
      }
      n2: (struct){
        x: ((null|struct)){ |((struct){
            a: (struct){
              b: (struct){
                c: (int){ 1 }
                d: (int){ 1 }
              }
            }
          }, (null){ null }) }
      }
    }
    eliminated: (struct){
      n1: (struct){
        p1: (struct){
          x: (null){ null }
        }
        p2: (struct){
          x: (null){ null }
        }
      }
      n2: (struct){
        p1: (struct){
          x: (null){ null }
        }
        p2: (struct){
          x: (null){ null }
        }
      }
    }
    incomplete: (struct){
      a: (struct){
        n1: (struct){
          p1: (struct){
            x: (null){ null }
          }
          p2: (struct){
            x: (null){ null }
          }
        }
        n2: (struct){
          p1: (struct){
            x: ((null|struct)){ |((struct){
                a: (struct){
                  b: (_|_){
                    // [incomplete] nestedNonMonotonic.incomplete.a.n2.p1.x.a.b: invalid value {c:1} (does not satisfy struct.MinFields(2)): len(fields) < MinFields(2) (1 < 2):
                    //     ./in.cue:96:15
                    //     ./in.cue:96:32
                    //     ./in.cue:97:12
                    c: (int){ 1 }
                  }
                }
              }, (null){ null }) }
          }
          p2: (struct){
            x: ((null|struct)){ |((struct){
                a: (struct){
                  b: (_|_){
                    // [incomplete] nestedNonMonotonic.incomplete.a.n2.p2.x.a.b: invalid value {c:1} (does not satisfy struct.MinFields(2)): len(fields) < MinFields(2) (1 < 2):
                    //     ./in.cue:102:15
                    //     ./in.cue:101:12
                    //     ./in.cue:102:32
                    c: (int){ 1 }
                  }
                }
              }, (null){ null }) }
          }
        }
      }
      b: (struct){
        n1: (struct){
          p1: (struct){
            x: (null){ null }
          }
          p2: (struct){
            x: (null){ null }
          }
          p3: (struct){
            x: (null){ null }
          }
        }
        n2: (struct){
          p1: (struct){
            x: ((null|struct)){ |((struct){
                a: (struct){
                  b: (_|_){
                    // [incomplete] nestedNonMonotonic.incomplete.b.n2.p1.x.a.b: invalid value {c:1 & 1 & 1,d:1 & 1 & 1} (does not satisfy struct.MinFields(3)): len(fields) < MinFields(3) (2 < 3):
                    //     ./in.cue:138:15
                    //     ./in.cue:124:15
                    //     ./in.cue:125:12
                    //     ./in.cue:126:12
                    //     ./in.cue:130:12
                    //     ./in.cue:131:15
                    //     ./in.cue:132:12
                    //     ./in.cue:136:12
                    //     ./in.cue:137:12
                    //     ./in.cue:138:32
                    c: (int){ 1 }
                    d: (int){ 1 }
                  }
                }
              }, (null){ null }) }
          }
        }
      }
    }
  }
  preserveClosedness: (struct){
    small: (struct){
      p1: (struct){
        #A: (#struct){ |(*(#struct){
            a: (string){ string }
          }, (#struct){
            a: (string){ string }
            b: (int){ int }
          }) }
        #B: (#struct){ |(*(#struct){
          }, (#struct){
            b: (int){ int }
          }, (#struct){
            a: (string){ string }
          }, (#struct){
            a: (string){ string }
            b: (int){ int }
          }) }
      }
      p2: (struct){
        #A: (#struct){ |(*(#struct){
            a: (string){ string }
          }, (#struct){
            a: (string){ string }
            b: (int){ int }
          }) }
        #B: (#struct){ |(*(#struct){
          }, (#struct){
            a: (string){ string }
            b: (int){ int }
          }, (#struct){
            a: (string){ string }
          }, (#struct){
            b: (int){ int }
          }) }
      }
    }
    medium: (struct){
      p1: (struct){
        #A: (#struct){ |(*(#struct){
            a: (string){ string }
          }, (#struct){
            a: (string){ string }
            c: (int){ int }
          }, (#struct){
            a: (string){ string }
            d: (string){ string }
          }) }
        #B: (#struct){ |(*(#struct){
          }, (#struct){
            c: (int){ int }
          }, (#struct){
            d: (string){ string }
          }, (#struct){
            a: (string){ string }
          }, (#struct){
            a: (string){ string }
            c: (int){ int }
          }, (#struct){
            a: (string){ string }
            d: (string){ string }
          }, (#struct){
            b: (string){ string }
          }, (#struct){
            b: (string){ string }
            c: (int){ int }
          }, (#struct){
            b: (string){ string }
            d: (string){ string }
          }) }
      }
      p2: (struct){
        #A: (#struct){ |(*(#struct){
            a: (string){ string }
          }, (#struct){
            a: (string){ string }
            c: (int){ int }
          }, (#struct){
            a: (string){ string }
            d: (string){ string }
          }) }
        #B: (#struct){ |(*(#struct){
          }, (#struct){
            a: (string){ string }
            c: (int){ int }
          }, (#struct){
            a: (string){ string }
            d: (string){ string }
          }, (#struct){
            a: (string){ string }
          }, (#struct){
            c: (int){ int }
          }, (#struct){
            d: (string){ string }
          }, (#struct){
            b: (string){ string }
          }, (#struct){
            b: (string){ string }
            c: (int){ int }
          }, (#struct){
            b: (string){ string }
            d: (string){ string }
          }) }
      }
      p3: (struct){
        #A: (#struct){ |(*(#struct){
            a: (string){ string }
          }, (#struct){
            a: (string){ string }
            c: (int){ int }
          }, (#struct){
            a: (string){ string }
            d: (string){ string }
          }) }
        #B: (#struct){ |(*(#struct){
          }, (#struct){
            a: (string){ string }
            c: (int){ int }
          }, (#struct){
            a: (string){ string }
            d: (string){ string }
          }, (#struct){
            b: (string){ string }
          }, (#struct){
            b: (string){ string }
            c: (int){ int }
          }, (#struct){
            b: (string){ string }
            d: (string){ string }
          }, (#struct){
            a: (string){ string }
          }, (#struct){
            c: (int){ int }
          }, (#struct){
            d: (string){ string }
          }) }
      }
    }
  }
  noChildError: (struct){
    issue1608: (struct){
      myValue: (#struct){
        fieldName: (string){ "some string" }
      }
      #type: (#struct){
        fieldName: ((string|struct)){ |((string){ string }, (#struct){
            foo: (string){ string }
          }, (#struct){
            bar: ((string|struct)){ |((string){ string }, (#struct){
                foo: (string){ string }
              }) }
          }) }
      }
      #subtype: ((string|struct)){ |((string){ string }, (#struct){
          foo: (string){ string }
        }) }
    }
    t1: (struct){
      #D: (#struct){
        b: (string){ string }
      }
      o: (#struct){
        b: (string){ "test" }
      }
    }
    t2: (struct){
      o: (#struct){
        b: (string){ "test" }
      }
      #D: (#struct){
        b: (string){ string }
      }
    }
    t3: (struct){
      #D: (#struct){ |((#struct){
          a: (null){ null }
        }, (#struct){
          b: (string){ string }
        }) }
      o: (#struct){
        b: (string){ "test" }
      }
    }
    t4: (struct){
      o: (#struct){
        b: (string){ "test" }
      }
      #D: (#struct){ |((#struct){
          a: (null){ null }
        }, (#struct){
          b: (string){ string }
        }) }
    }
  }
  issue1924: (struct){
    t1: (struct){
      m: (struct){
        a: (int){ 2 }
      }
      x: (int){ 2 }
    }
    t2: (struct){
      m: (struct){
        a: (int){ 2 }
      }
      x: (int){ 3 }
    }
    t3: (struct){
      m: (struct){
        a: (int){ 2 }
      }
      x: (int){ 1 }
    }
  }
  issue1838: (struct){
    t1: (struct){
      p?: (#list){
      }
      a: (null){ null }
    }
    t2: (struct){
      p?: (#list){
      }
      a: (null){ null }
    }
  }
  noHang: (struct){
    #T: (list){
      0: (string){ "d" }
    }
    x: (list){
      0: (string){ "d" }
    }
    #X: (list){
      0: (string){ "d" }
    }
  }
  issue1940: (struct){
    #T: (#list){
      0: (string){ "d" }
      1: (list){
      }
    }
    #A: (#struct){
      type: (#list){
        0: (string){ "d" }
        1: (list){
        }
      }
    }
    #B: (#struct){
    }
    #C: (#struct){
      x: (#struct){
        type: (#list){
          0: (string){ "d" }
          1: (list){
          }
        }
      }
    }
  }
  issue1417: (_|_){
    // [eval]
    #ID: (string){ |((string){ &(!~"^a", =~"^a") }, (string){ &(!~"^a", !~"[A-Z]") }, (string){ &(=~"^ab$", =~"^a") }, (string){ &(=~"^ab$", !~"[A-Z]") }, (string){ &(=~"^aB$", =~"^a") }, (string){ &(=~"^aB$", !~"[A-Z]") }) }
    ids: (_|_){
      // [eval]
      0: (string){ "xyz" }
      1: (_|_){
        // [eval] issue1417.ids.1: invalid value "ab" (out of bound !~"^a"):
        //     ./issue1417.cue:2:7
        //     ./issue1417.cue:4:11
        //     ./issue1417.cue:4:26
      }
      2: (_|_){
        // [eval] issue1417.ids.2: 2 errors in empty disjunction:
        // issue1417.ids.2: invalid value "aB" (out of bound !~"^a"):
        //     ./issue1417.cue:2:7
        //     ./issue1417.cue:4:11
        //     ./issue1417.cue:4:32
        // issue1417.ids.2: invalid value "aB" (out of bound !~"[A-Z]"):
        //     ./issue1417.cue:3:16
        //     ./issue1417.cue:4:11
        //     ./issue1417.cue:4:32
      }
    }
  }
  issue2209: (_|_){
    // [eval]
    simplified: (_|_){
      // [eval]
      t1: (struct){
        #SpecFoo: (#struct){
          foo: (#struct){
            min: (int){ 1 }
          }
        }
        #SpecBar: (#struct){
          bar: (#struct){
            min: (int){ 1 }
          }
        }
        spec: (#struct){
          bar: (#struct){
            min: (int){ 1 }
          }
        }
        out: (struct){ |((struct){
            X: (#struct){
              bar: (#struct){
                min: (int){ 1 }
              }
            }
            nullFoo: (null){ null }
            minFoo: (int){ int }
          }, (struct){
            minBar: (int){ int }
            X: (#struct){
              bar: (#struct){
                min: (int){ 1 }
              }
            }
            nullFoo: (null){ null }
          }, (struct){
            X: (#struct){
              bar: (#struct){
                min: (int){ 1 }
              }
            }
            nullBar: (null){ null }
            minFoo: (int){ int }
          }, (struct){
            minBar: (int){ int }
            X: (#struct){
              bar: (#struct){
                min: (int){ 1 }
              }
            }
            nullBar: (null){ null }
          }) }
      }
      t2: (_|_){
        // [incomplete] issue2209.simplified.t2.BAZ: undefined field: x:
        //     ./issue2209full.cue:24:17
        #SpecFoo: (#struct){
          foo: (#struct){
          }
        }
        #SpecBar: (#struct){
          bar: (#struct){
            x: (int){ 1 }
          }
        }
        spec: (#struct){ |(*(#struct){
            bar: (struct){
            }
            foo: (#struct){
            }
          }, (#struct){
            bar: (#struct){
              x: (int){ 1 }
            }
          }) }
        BAZ: (_|_){
          // [incomplete] issue2209.simplified.t2.BAZ: undefined field: x:
          //     ./issue2209full.cue:24:17
        }
        b2: (int){ int }
      }
      t3: (_|_){
        // [eval] issue2209.simplified.t3.BAZ: undefined field: y:
        //     ./issue2209full.cue:35:9
        #A: (#struct){
          v: (int){ 1 }
        }
        BAZ: (_|_){
          // [eval] issue2209.simplified.t3.BAZ: undefined field: y:
          //     ./issue2209full.cue:35:9
        }
        S: (#struct){ |(*(#struct){
            x: (int){ 1 }
            v: (int){ 1 }
          }, (#struct){
            x: (int){ 1 }
            y: (int){ 1 }
          }) }
        #B: (#struct){
          x: (int){ 1 }
          y: (int){ 1 }
        }
        b2: (int){ int }
      }
    }
    full: (_|_){
      // [eval]
      Foo: (#struct){
        spec: (#struct){
          foo: (#struct){
            min: (int){ |(*(int){ 10 }, (int){ int }) }
            max: (int){ |(*(int){ 20 }, (int){ int }) }
          }
        }
        resource: (#struct){
          spec: (#struct){ |(*(#struct){
              minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
              maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
              minBar?: (null){ null }
              maxBar?: (null){ null }
              hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
              fuga?: (null){ null }
            }, (#struct){
              minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
              maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
              minBar?: (null){ null }
              maxBar?: (null){ null }
              hoge?: (null){ null }
              fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
            }) }
          _X: (#struct){
            spec: (#struct){ |(*(#struct){
                foo: (#struct){
                  min: (int){ |(*(int){ 10 }, (int){ int }) }
                  max: (int){ |(*(int){ 20 }, (int){ int }) }
                }
              }, (#struct){
                foo: (#struct){
                }
                bar: (#struct){
                  min: (int){ |(*(int){ 30 }, (int){ int }) }
                  max: (int){ |(*(int){ 40 }, (int){ int }) }
                }
              }) }
          }
        }
      }
      Bar: (_|_){
        // [eval]
        spec: (#struct){
          bar: (#struct){
            min: (int){ |(*(int){ 30 }, (int){ int }) }
            max: (int){ |(*(int){ 40 }, (int){ int }) }
          }
        }
        resource: (_|_){
          // [eval]
          spec: (_|_){
            // [eval] issue2209.full.Bar.resource.spec: 6 errors in empty disjunction:
            // issue2209.full.Bar.resource.spec.minBar: 2 errors in empty disjunction:
            // issue2209.full.Bar.resource.spec.minBar: conflicting values null and int (mismatched types null and int):
            //     ./issue2209full.cue:43:7
            //     ./issue2209full.cue:48:13
            //     ./issue2209full.cue:67:10
            //     ./issue2209full.cue:83:16
            //     ./issue2209full.cue:87:13
            //     ./issue2209full.cue:107:20
            // issue2209.full.Bar.resource.spec.minFoo: 2 errors in empty disjunction:
            // issue2209.full.Bar.resource.spec.minFoo: conflicting values null and 10 (mismatched types null and int):
            //     ./issue2209full.cue:43:7
            //     ./issue2209full.cue:48:13
            //     ./issue2209full.cue:55:16
            //     ./issue2209full.cue:71:4
            //     ./issue2209full.cue:72:13
            //     ./issue2209full.cue:92:13
            // issue2209.full.Bar.resource.spec.minFoo: conflicting values null and int (mismatched types null and int):
            //     ./issue2209full.cue:43:7
            //     ./issue2209full.cue:48:13
            //     ./issue2209full.cue:67:10
            //     ./issue2209full.cue:83:16
            //     ./issue2209full.cue:92:13
            //     ./issue2209full.cue:105:20
            // issue2209.full.Bar.resource.spec.minBar: undefined field: min:
            //     ./issue2209full.cue:77:25
            minFoo: (_|_){
              // [eval] issue2209.full.Bar.resource.spec.minFoo: 2 errors in empty disjunction:
              // issue2209.full.Bar.resource.spec.minFoo: conflicting values null and 10 (mismatched types null and int):
              //     ./issue2209full.cue:43:7
              //     ./issue2209full.cue:48:13
              //     ./issue2209full.cue:55:16
              //     ./issue2209full.cue:71:4
              //     ./issue2209full.cue:72:13
              //     ./issue2209full.cue:92:13
              // issue2209.full.Bar.resource.spec.minFoo: conflicting values null and int (mismatched types null and int):
              //     ./issue2209full.cue:43:7
              //     ./issue2209full.cue:48:13
              //     ./issue2209full.cue:67:10
              //     ./issue2209full.cue:83:16
              //     ./issue2209full.cue:92:13
              //     ./issue2209full.cue:105:20
            }
            maxFoo: (_|_){
              // [eval] issue2209.full.Bar.resource.spec.maxFoo: 2 errors in empty disjunction:
              // issue2209.full.Bar.resource.spec.maxFoo: conflicting values null and 20 (mismatched types null and int):
              //     ./issue2209full.cue:43:7
              //     ./issue2209full.cue:48:13
              //     ./issue2209full.cue:56:16
              //     ./issue2209full.cue:71:4
              //     ./issue2209full.cue:73:13
              //     ./issue2209full.cue:93:13
              // issue2209.full.Bar.resource.spec.maxFoo: conflicting values null and int (mismatched types null and int):
              //     ./issue2209full.cue:43:7
              //     ./issue2209full.cue:48:13
              //     ./issue2209full.cue:67:10
              //     ./issue2209full.cue:83:16
              //     ./issue2209full.cue:93:13
              //     ./issue2209full.cue:106:20
            }
            minBar: (_|_){
              // [eval] issue2209.full.Bar.resource.spec.minBar: undefined field: min:
              //     ./issue2209full.cue:77:25
            }
            maxBar: (_|_){
              // [eval] issue2209.full.Bar.resource.spec.maxBar: undefined field: max:
              //     ./issue2209full.cue:78:25
            }
            hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
            fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
          }
          _X: (#struct){
            spec: (#struct){ |(*(#struct){
                bar: (#struct){
                }
                foo: (#struct){
                  min: (int){ |(*(int){ 10 }, (int){ int }) }
                  max: (int){ |(*(int){ 20 }, (int){ int }) }
                }
              }, (#struct){
                bar: (#struct){
                  min: (int){ |(*(int){ 30 }, (int){ int }) }
                  max: (int){ |(*(int){ 40 }, (int){ int }) }
                }
              }) }
          }
        }
      }
      #Abstract: (#struct){
        spec: (#struct){ |(*(#struct){
            foo: (#struct){
              min: (int){ |(*(int){ 10 }, (int){ int }) }
              max: (int){ |(*(int){ 20 }, (int){ int }) }
            }
          }, (#struct){
            bar: (#struct){
              min: (int){ |(*(int){ 30 }, (int){ int }) }
              max: (int){ |(*(int){ 40 }, (int){ int }) }
            }
          }) }
        resource: (#struct){
          spec: (#struct){ |(*(#struct){
              minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
              maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
              minBar?: (null){ null }
              maxBar?: (null){ null }
              hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
              fuga?: (null){ null }
            }, (#struct){
              minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
              maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
              minBar?: (null){ null }
              maxBar?: (null){ null }
              hoge?: (null){ null }
              fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
            }) }
          _X: (#struct){
            spec: (#struct){ |(*(#struct){
                foo: (#struct){
                  min: (int){ |(*(int){ 10 }, (int){ int }) }
                  max: (int){ |(*(int){ 20 }, (int){ int }) }
                }
              }, (#struct){
                bar: (#struct){
                  min: (int){ |(*(int){ 30 }, (int){ int }) }
                  max: (int){ |(*(int){ 40 }, (int){ int }) }
                }
              }) }
          }
        }
      }
      _#Spec: (#struct){ |(*(#struct){
          foo: (#struct){
            min: (int){ |(*(int){ 10 }, (int){ int }) }
            max: (int){ |(*(int){ 20 }, (int){ int }) }
          }
        }, (#struct){
          bar: (#struct){
            min: (int){ |(*(int){ 30 }, (int){ int }) }
            max: (int){ |(*(int){ 40 }, (int){ int }) }
          }
        }) }
      _#SpecFoo: (#struct){
        foo: (#struct){
          min: (int){ |(*(int){ 10 }, (int){ int }) }
          max: (int){ |(*(int){ 20 }, (int){ int }) }
        }
      }
      _#SpecBar: (#struct){
        bar: (#struct){
          min: (int){ |(*(int){ 30 }, (int){ int }) }
          max: (int){ |(*(int){ 40 }, (int){ int }) }
        }
      }
      _Thing: (#struct){
        spec: (#struct){ |(*(#struct){
            minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
            maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
            minBar?: (null){ null }
            maxBar?: (null){ null }
            hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
            fuga?: (null){ null }
          }, *(#struct){
            minFoo?: (null){ null }
            maxFoo?: (null){ null }
            minBar: (int){ |(*(int){ 30 }, (int){ int }) }
            maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
            hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
            fuga?: (null){ null }
          }, (#struct){
            minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
            maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
            minBar?: (null){ null }
            maxBar?: (null){ null }
            hoge?: (null){ null }
            fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
          }, (#struct){
            minFoo?: (null){ null }
            maxFoo?: (null){ null }
            minBar: (int){ |(*(int){ 30 }, (int){ int }) }
            maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
            hoge?: (null){ null }
            fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
          }) }
        _X: (_){ _ }
      }
      #Constrained: (#struct){
        spec: (#struct){ |(*(#struct){
            minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
            maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
            minBar?: (null){ null }
            maxBar?: (null){ null }
            hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
            fuga?: (null){ null }
          }, *(#struct){
            minFoo?: (null){ null }
            maxFoo?: (null){ null }
            minBar: (int){ |(*(int){ 30 }, (int){ int }) }
            maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
            hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
            fuga?: (null){ null }
          }, (#struct){
            minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
            maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
            minBar?: (null){ null }
            maxBar?: (null){ null }
            hoge?: (null){ null }
            fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
          }, (#struct){
            minFoo?: (null){ null }
            maxFoo?: (null){ null }
            minBar: (int){ |(*(int){ 30 }, (int){ int }) }
            maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
            hoge?: (null){ null }
            fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
          }) }
      }
      #Base: (#struct){
        spec: (#struct){
          minFoo?: ((null|int)){ |((null){ null }, (int){ int }) }
          maxFoo?: ((null|int)){ |((null){ null }, (int){ int }) }
          minBar?: ((null|int)){ |((null){ null }, (int){ int }) }
          maxBar?: ((null|int)){ |((null){ null }, (int){ int }) }
          hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
          fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
        }
      }
    }
  }
  issue2246: (struct){
    simplified: (struct){
      #FormFoo: (#struct){
        fooID: (string){ string }
      }
      #FormBar: (#struct){
        barID: (string){ string }
      }
      #Form: (#struct){ |((#struct){
          fooID: (string){ string }
        }, (#struct){
          barID: (string){ string }
        }) }
      data: (struct){
        fooID: (string){ "123" }
      }
      out1: (#struct){
        fooID: (string){ "123" }
      }
      out2: (#struct){
        fooID: (string){ "123" }
      }
    }
    full: (struct){
      data: (struct){
        forms: (#list){
          0: (struct){
            fooID: (string){ "00-0000001" }
          }
        }
      }
      form1040: (#list){
        0: (int){ 3 }
      }
      #K1: (#struct){
        #_base: (#struct){
          common: (int){ 3 }
        }
        #FormFoo: (#struct){
          common: (int){ 3 }
          fooID: (string){ string }
        }
        #FormBar: (#struct){
          common: (int){ 3 }
          barID: (string){ string }
        }
        #Form: (#struct){ |((#struct){
            common: (int){ 3 }
            fooID: (string){ string }
          }, (#struct){
            common: (int){ 3 }
            barID: (string){ string }
          }) }
      }
      #Input: (#struct){
        forms: (list){
        }
      }
      #summarizeReturn: (#struct){
        in: (#struct){
          forms: (list){
          }
        }
        out: (#list){
        }
      }
      #compute: (#struct){
        in: (#struct){
          forms: (list){
          }
        }
        out: (#list){
        }
      }
    }
  }
  issue2263: (struct){
    simplified: (struct){
      metrics: (#struct){
        id: (string){ "foo" }
        avg: (int){ 60 }
      }
      #Metric: (#struct){ |((#struct){
          id: (string){ string }
          avg: (number){ number }
        }, (#struct){
          id: (string){ string }
        }, (#struct){
          avg: (number){ number }
        }, (#struct){
        }) }
      #IDSource: (#struct){
        id: (string){ string }
      }
      #TargetAverage: (#struct){
        avg: (number){ number }
      }
    }
    full: (struct){
      metrics: (#list){
        0: (#struct){
          id: (string){ "foo" }
          avg: (int){ 60 }
        }
        1: (#struct){
          id: (string){ "bar" }
          value: (int){ 80 }
        }
        2: (#struct){
          uri: (string){ "baz" }
          avg: (int){ 70 }
        }
        3: (#struct){
          uri: (string){ "qux" }
          value: (int){ 90 }
        }
      }
      #Metric: (#struct){ |((#struct){
          id: (string){ string }
          avg: (number){ number }
        }, (#struct){
          id: (string){ string }
          value: (number){ number }
        }, (#struct){
          uri: (string){ string }
          avg: (number){ number }
        }, (#struct){
          uri: (string){ string }
          value: (number){ number }
        }) }
      #Source: (#struct){ |((#struct){
          id: (string){ string }
        }, (#struct){
          uri: (string){ string }
        }) }
      #Target: (#struct){ |((#struct){
          avg: (number){ number }
        }, (#struct){
          value: (number){ number }
        }) }
      #IDSource: (#struct){
        id: (string){ string }
      }
      #URISource: (#struct){
        uri: (string){ string }
      }
      #TargetAverage: (#struct){
        avg: (number){ number }
      }
      #TargetValue: (#struct){
        value: (number){ number }
      }
    }
  }
  issue3149: (_|_){
    // [eval]
    #valid: (#struct){
      name!: (string){ |((string){ &(=~"^Foo", =~"Foo$") }, (string){ "an exception" }) }
    }
    list: (_|_){
      // [eval]
      0: (#struct){
        name: (string){ "FooBarFoo" }
      }
      1: (#struct){
        name: (string){ "FooBazFoo" }
      }
      2: (#struct){
        name: (string){ "FooQuuxFoo" }
      }
      3: (_|_){
        // [eval]
        name: (_|_){
          // [eval] issue3149.list.3.name: 2 errors in empty disjunction:
          // issue3149.list.3.name: invalid value "an exception" (out of bound =~"^Foo"):
          //     ./issue3149.cue:3:13
          //     ./issue3149.cue:3:10
          //     ./issue3149.cue:10:10
          // issue3149.list.3.name: invalid value "an exception" (out of bound =~"Foo$"):
          //     ./issue3149.cue:3:46
          //     ./issue3149.cue:3:10
          //     ./issue3149.cue:10:10
        }
      }
    }
  }
  issue3528: (struct){
    original: (struct){
      workflows: (#list){
        0: (#struct){
          container: (#struct){
          }
          #container: ((string|struct)){ |((string){ string }, (#struct){
              volumes?: (list){
              }
            }) }
        }
      }
      test: (#struct){
        container: (#struct){
        }
        #container: ((string|struct)){ |((string){ string }, (#struct){
            volumes?: (list){
            }
          }) }
      }
      #Workflow: (#struct){
        container: (#struct){
        }
        #container: ((string|struct)){ |((string){ string }, (#struct){
            volumes?: (list){
            }
          }) }
      }
    }
    reduced: (struct){
      a: (#struct){
        A: (#struct){
        }
        #a: ((int|struct)){ |((int){ 2 }, (#struct){
            v: (int){ 1 }
          }) }
      }
      #A: (#struct){
        A: (#struct){
        }
        #a: ((int|struct)){ |((int){ 2 }, (#struct){
            v: (int){ 1 }
          }) }
      }
    }
    counter: (struct){
    }
    nested: (struct){
      t1: ((int|struct)){ |((struct){
          v: (int){ 1 }
        }, (int){ 2 }, (int){ 3 }) }
      t2: ((int|struct)){ |((struct){
          v: (int){ 1 }
        }, (int){ 2 }) }
    }
  }
  issue3784: (struct){
    reduced: (struct){
      #Schema: (#struct){
        a: (#struct){ |((#struct){
            kind: (string){ "A" }
            b: (#struct){
              c?: (string){ string }
            }
          }, (#struct){
            kind: (string){ "B" }
          }) }
      }
      out: (#struct){
        a: (#struct){
          kind: (string){ "A" }
          b: (#struct){
            c: (string){ "x" }
          }
        }
      }
    }
    full: (struct){
      #Schema: (#struct){
        pages?: (#struct){ |((#struct){
            build_type!: (string){ "legacy" }
            source!: (#struct){
              branch!: (string){ string }
              path?: (string){ string }
            }
            cname?: (string){ string }
          }, (#struct){
            build_type!: (string){ "workflow" }
            source?: (#struct){
              branch?: (string){ string }
              path?: (string){ string }
            }
            cname?: (string){ string }
          }) }
      }
      out: (#struct){
        pages: (#struct){
          build_type: (string){ "legacy" }
          source: (#struct){
            branch: (string){ "main" }
            path: (string){ "/" }
          }
          cname: (string){ "foo.com" }
        }
      }
    }
    variant1: (struct){
      #Schema: (#struct){
        pages: (#struct){
          build_type!: (string){ "legacy" }
          source: (#struct){
            branch!: (string){ string }
            path?: (string){ string }
          }
          cname?: (string){ string }
        }
      }
    }
    variant2: (struct){
      #Schema: (#struct){ |((#struct){
          build_type!: (string){ "legacy" }
          source!: (#struct){
            branch!: (_){ _ }
          }
        }, (#struct){
          build_type!: (string){ "workflow" }
          cname?: (_){ _ }
        }) }
      a: (#struct){
        build_type!: (string){ "legacy" }
        source: (#struct){
          branch!: (string){ string }
          path?: (string){ string }
        }
        cname?: (string){ string }
      }
    }
  }
  issue3958: (struct){
    t1: (struct){
      #schema: (int){ |((int){ int }, (int){ 3 }, (int){ 1 }) }
      test1: (int){ |((int){ int }, (int){ 2 }, (int){ 3 }, (int){ 1 }) }
      test2: (int){ |((int){ int }, (int){ 4 }, (int){ 3 }, (int){ 1 }) }
    }
    t2: (struct){
      a: (int){ |((int){ int }, (int){ 8 }, (int){ 3 }, (int){ 1 }, (int){ 4 }) }
      b: (int){ |((int){ int }, (int){ 3 }, (int){ 1 }, (int){ 4 }) }
    }
  }
  issue770: (struct){
    #A: (#struct){
      v: (string){ |((string){ "a" }, (string){ "b" }, (string){ "c" }) }
    }
    h: (struct){
      a: (#struct){
        v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) }
      }
      b: (#struct){
        v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) }
      }
      boo: (#struct){
        v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) }
      }
      c: (#struct){
        v: (string){ |(*(string){ "a" }, *(string){ "b" }, *(string){ "c" }) }
      }
      coo: (#struct){
        v: (string){ |(*(string){ "a" }, *(string){ "b" }, *(string){ "c" }) }
      }
    }
  }
}
-- out/compile --
--- in.cue
{
  disambiguateClosed: {
    b: (〈0;#Def〉 & 〈0;a〉)
    a: 〈0;#Def〉
    #Def: {
      ({
        x: true
      }|{
        y: true
      })
    }
  }
  alwaysCheckMatchers1: {
    b: ({
      [=~"^xxxx$"]: int
    }|null)
    b: ({
      c: string
    }|null)
    b: {
      c: "yyyyy"
    }
  }
  alwaysCheckPatterns2: {
    a: 〈0;#X〉
    a: 〈0;b〉
    b: 〈0;#X〉
    b: {
      c: "yyyyy"
    }
    #X: (string|{
      c: string
      {
        [=~"^xxxx$"]: int
      }
    })
  }
  nestedNonMonotonic: {
    resolved: {
      n1: {
        x: ({
          a: 〈import;struct〉.MinFields(2)
        }|null)
        x: ({
          a: {
            c: 1
          }
        }|null)
        x: ({
          a: {
            d: 1
          }
        }|null)
      }
    }
  }
  nestedNonMonotonic: {
    resolved: {
      n2: {
        x: ({
          a: {
            b: 〈import;struct〉.MinFields(2)
          }
        }|null)
        x: ({
          a: {
            b: {
              c: 1
            }
          }
        }|null)
        x: ({
          a: {
            b: {
              d: 1
            }
          }
        }|null)
      }
    }
  }
  nestedNonMonotonic: {
    eliminated: {
      n1: {
        p1: {
          x: ({
            a: 〈import;struct〉.MaxFields(1)
          }|null)
          x: ({
            a: {
              c: 1
            }
          }|null)
          x: ({
            a: {
              d: 1
            }
          }|null)
        }
      }
    }
  }
  nestedNonMonotonic: {
    eliminated: {
      n1: {
        p2: {
          x: ({
            a: {
              c: 1
            }
          }|null)
          x: ({
            a: 〈import;struct〉.MaxFields(1)
          }|null)
          x: ({
            a: {
              d: 1
            }
          }|null)
        }
      }
    }
  }
  nestedNonMonotonic: {
    eliminated: {
      n1: {
        p2: {
          x: ({
            a: {
              c: 1
            }
          }|null)
          x: ({
            a: {
              d: 1
            }
          }|null)
          x: ({
            a: 〈import;struct〉.MaxFields(1)
          }|null)
        }
      }
    }
  }
  nestedNonMonotonic: {
    eliminated: {
      n2: {
        p1: {
          x: ({
            a: {
              b: 〈import;struct〉.MaxFields(1)
            }
          }|null)
          x: ({
            a: {
              b: {
                c: 1
              }
            }
          }|null)
          x: ({
            a: {
              b: {
                d: 1
              }
            }
          }|null)
        }
      }
    }
  }
  nestedNonMonotonic: {
    eliminated: {
      n2: {
        p2: {
          x: ({
            a: {
              b: {
                c: 1
              }
            }
          }|null)
          x: ({
            a: {
              b: 〈import;struct〉.MaxFields(1)
            }
          }|null)
          x: ({
            a: {
              b: {
                d: 1
              }
            }
          }|null)
        }
      }
    }
  }
  nestedNonMonotonic: {
    eliminated: {
      n2: {
        p2: {
          x: ({
            a: {
              b: {
                c: 1
              }
            }
          }|null)
          x: ({
            a: {
              b: {
                d: 1
              }
            }
          }|null)
          x: ({
            a: {
              b: 〈import;struct〉.MaxFields(1)
            }
          }|null)
        }
      }
    }
  }
  nestedNonMonotonic: {
    incomplete: {
      a: {
        n1: {
          p1: {
            x: ({
              a: 〈import;struct〉.MinFields(2)
            }|null)
            x: ({
              a: {
                c: 1
              }
            }|null)
          }
        }
      }
    }
  }
  nestedNonMonotonic: {
    incomplete: {
      a: {
        n1: {
          p2: {
            x: ({
              a: {
                c: 1
              }
            }|null)
            x: ({
              a: 〈import;struct〉.MinFields(2)
            }|null)
          }
        }
      }
    }
  }
  nestedNonMonotonic: {
    incomplete: {
      a: {
        n2: {
          p1: {
            x: ({
              a: {
                b: 〈import;struct〉.MinFields(2)
              }
            }|null)
            x: ({
              a: {
                b: {
                  c: 1
                }
              }
            }|null)
          }
        }
      }
    }
  }
  nestedNonMonotonic: {
    incomplete: {
      a: {
        n2: {
          p2: {
            x: ({
              a: {
                b: {
                  c: 1
                }
              }
            }|null)
            x: ({
              a: {
                b: 〈import;struct〉.MinFields(2)
              }
            }|null)
          }
        }
      }
    }
  }
  nestedNonMonotonic: {
    incomplete: {
      b: {
        n1: {
          p1: {
            x: ({
              a: 〈import;struct〉.MinFields(3)
            }|null)
            x: ({
              a: {
                c: 1
              }
            }|null)
            x: ({
              a: {
                d: 1
              }
            }|null)
          }
        }
      }
    }
  }
  nestedNonMonotonic: {
    incomplete: {
      b: {
        n1: {
          p2: {
            x: ({
              a: {
                c: 1
              }
            }|null)
            x: ({
              a: 〈import;struct〉.MinFields(3)
            }|null)
            x: ({
              a: {
                d: 1
              }
            }|null)
          }
        }
      }
    }
  }
  nestedNonMonotonic: {
    incomplete: {
      b: {
        n1: {
          p3: {
            x: ({
              a: {
                c: 1
              }
            }|null)
            x: ({
              a: {
                d: 1
              }
            }|null)
            x: ({
              a: 〈import;struct〉.MinFields(3)
            }|null)
          }
        }
      }
    }
  }
  nestedNonMonotonic: {
    incomplete: {
      b: {
        n2: {
          p1: {
            x: ({
              a: {
                b: 〈import;struct〉.MinFields(3)
              }
            }|null)
            x: ({
              a: {
                b: {
                  c: 1
                }
              }
            }|null)
            x: ({
              a: {
                b: {
                  d: 1
                }
              }
            }|null)
          }
        }
      }
    }
  }
  nestedNonMonotonic: {
    incomplete: {
      b: {
        n2: {
          p1: {
            x: ({
              a: {
                b: {
                  c: 1
                }
              }
            }|null)
            x: ({
              a: {
                b: 〈import;struct〉.MinFields(3)
              }
            }|null)
            x: ({
              a: {
                b: {
                  d: 1
                }
              }
            }|null)
          }
        }
      }
    }
  }
  nestedNonMonotonic: {
    incomplete: {
      b: {
        n2: {
          p1: {
            x: ({
              a: {
                b: {
                  c: 1
                }
              }
            }|null)
            x: ({
              a: {
                b: {
                  d: 1
                }
              }
            }|null)
            x: ({
              a: {
                b: 〈import;struct〉.MinFields(3)
              }
            }|null)
          }
        }
      }
    }
  }
  preserveClosedness: {
    small: {
      p1: {
        #A: (〈0;#B〉 & {
          a: string
        })
        #B: {
          (*{}|{
            a: string
          })
          (*{}|{
            b: int
          })
        }
      }
    }
  }
  preserveClosedness: {
    small: {
      p2: {
        #A: (〈0;#B〉 & {
          a: string
        })
        #B: {
          ({
            a: string
          }|*{})
          (*{}|{
            b: int
          })
        }
      }
    }
  }
  preserveClosedness: {
    medium: {
      p1: {
        #A: (〈0;#B〉 & {
          a: string
        })
        #B: {
          (*{}|{
            a: string
          }|{
            b: string
          })
          (*{}|{
            c: int
          }|{
            d: string
          })
        }
      }
    }
  }
  preserveClosedness: {
    medium: {
      p2: {
        #A: (〈0;#B〉 & {
          a: string
        })
        #B: {
          ({
            a: string
          }|*{}|{
            b: string
          })
          (*{}|{
            c: int
          }|{
            d: string
          })
        }
      }
    }
  }
  preserveClosedness: {
    medium: {
      p3: {
        #A: (〈0;#B〉 & {
          a: string
        })
        #B: {
          ({
            a: string
          }|{
            b: string
          }|*{})
          (*{}|{
            c: int
          }|{
            d: string
          })
        }
      }
    }
  }
  noChildError: _
  noChildError: {
    issue1608: {
      myValue: (〈0;#type〉 & {
        fieldName: "some string"
      })
      #type: {
        fieldName: 〈1;#subtype〉
      }
      #subtype: (string|{
        foo: string
      }|{
        bar: 〈1;#subtype〉
      })
    }
  }
  noChildError: {
    t1: {
      #D: ({
        b: string
      }|{
        c: 〈1;#D〉
      })
      o: (〈0;#D〉 & {
        b: "test"
      })
    }
  }
  noChildError: {
    t2: {
      o: (〈0;#D〉 & {
        b: "test"
      })
      #D: ({
        b: string
      }|{
        c: 〈1;#D〉
      })
    }
  }
  noChildError: {
    t3: {
      #D: ({
        a: null
      }|{
        b: string
      }|{
        c: 〈1;#D〉
      })
      o: (〈0;#D〉 & {
        b: "test"
      })
    }
  }
  noChildError: {
    t4: {
      o: (〈0;#D〉 & {
        b: "test"
      })
      #D: ({
        a: null
      }|{
        b: string
      }|{
        c: 〈1;#D〉
      })
    }
  }
  issue1924: {
    t1: {
      m: {
        a: 2
      }
      x: (*[
        〈1;m〉.b,
      ]|2)
    }
  }
  issue1924: {
    t2: {
      m: {
        a: 2
      }
      x: (*{
        v: 〈1;m〉.b
      }|3)
    }
  }
  issue1924: {
    t3: {
      m: {
        a: 2
      }
      x: (*〈0;m〉.b|1)
    }
  }
  issue1838: {
    t1: {
      p?: []
      a: ([
        for _, k in 〈1;p〉 {
          〈1;k〉
        },
      ]|null)
    }
  }
  issue1838: {
    t2: {
      p?: []
      a: (null|[
        for _, k in 〈1;p〉 {
          〈1;k〉
        },
      ])
    }
  }
  noHang: {
    #T: ([
      "a",
      〈1;#T〉,
    ]|[
      "d",
      ...〈1;#T〉,
    ])
    x: 〈0;#T〉
    #X: 〈0;x〉
    #X: 〈0;#T〉
  }
  issue1940: {
    #T: ([
      "a",
      〈1;#T〉,
    ]|[
      "b",
      〈1;#T〉,
    ]|[
      "c",
      〈1;#T〉,
    ]|[
      "d",
      [
        ...〈2;#T〉,
      ],
    ])
    #A: {
      type: 〈1;#T〉
    }
    #B: {
      [string]: 〈1;#A〉
    }
    #C: (〈0;#B〉 & {
      x: 〈1;#A〉
    })
  }
}
--- issue1417.cue
{
  issue1417: {
    #ID: (!~"^a"|=~"^ab$"|=~"^aB$")
    #ID: (=~"^a"|!~"[A-Z]")
    ids: ([
      ...〈1;#ID〉,
    ] & [
      "xyz",
      "ab",
      "aB",
    ])
  }
}
--- issue2209full.cue
{
  issue2209: {
    simplified: {
      t1: {
        #SpecFoo: {
          foo: {
            min: 1
          }
        }
        #SpecBar: {
          bar: {
            min: 1
          }
        }
        spec: {
          bar: {}
        }
        spec: (〈0;#SpecFoo〉|〈0;#SpecBar〉)
        out: {
          ({
            nullFoo: null
          }|{
            nullBar: null
          })
          ({
            minFoo: int
          }|{
            minBar: int
          })
          if (〈0;X〉.bar != _|_(explicit error (_|_ literal) in source)) {
            minBar: 〈1;X〉.bar.min
          }
          X: 〈1;spec〉
        }
      }
    }
  }
  issue2209: {
    simplified: {
      t2: {
        #SpecFoo: {
          foo: {}
        }
        #SpecBar: {
          bar: {
            x: 1
          }
        }
        spec: {
          bar: {}
        }
        spec: (*〈0;#SpecFoo〉|〈0;#SpecBar〉)
        if (〈0;spec〉.bar != _|_(explicit error (_|_ literal) in source)) {
          BAZ: 〈1;spec〉.bar.x
        }
        ({
          f1: int
        }|{
          b2: int
        })
        ({
          f2: int
        }|{
          b2: int
        })
      }
    }
  }
  issue2209: {
    simplified: {
      t3: {
        #A: {
          v: 1
        }
        ({
          f1: int
        }|{
          b2: int
        })
        ({
          f2: int
        }|{
          b2: int
        })
        BAZ: 〈0;S〉.y
        S: (*〈0;#A〉|〈0;#B〉)
        #B: {
          x: 1
          y: 1
        }
        S: {
          x: 1
        }
      }
    }
  }
  issue2209: {
    full: {
      Foo: (〈0;#Abstract〉 & {
        spec: {
          foo: {}
        }
      })
      Bar: (〈0;#Abstract〉 & {
        spec: {
          bar: {}
        }
      })
      #Abstract: {
        spec: 〈1;_#Spec〉
        resource: (〈1;_Thing〉 & {
          _X: {
            spec: 〈3〉.spec
          }
        })
      }
      _#Spec: (*〈0;_#SpecFoo〉|〈0;_#SpecBar〉)
      _#SpecFoo: {
        foo: {
          min: (int|*10)
          max: (int|*20)
        }
      }
      _#SpecBar: {
        bar: {
          min: (int|*30)
          max: (int|*40)
        }
      }
      _Thing: (〈0;#Constrained〉 & {
        _X: _
        spec: {
          if (〈1;_X〉.spec.foo != _|_(explicit error (_|_ literal) in source)) {
            minFoo: 〈2;_X〉.spec.foo.min
            maxFoo: 〈2;_X〉.spec.foo.max
          }
          if (〈1;_X〉.spec.bar != _|_(explicit error (_|_ literal) in source)) {
            minBar: 〈2;_X〉.spec.bar.min
            maxBar: 〈2;_X〉.spec.bar.max
          }
        }
      })
      #Constrained: (〈0;#Base〉 & {
        spec: ({
          minFoo: (int|*10)
          maxFoo: (int|*20)
          minBar?: null
          maxBar?: null
        }|{
          minBar: (int|*30)
          maxBar: (int|*40)
          minFoo?: null
          maxFoo?: null
        })
        spec: (*{
          fuga?: null
        }|{
          hoge?: null
        })
      })
      #Base: {
        spec: {
          minFoo?: (null|int)
          maxFoo?: (null|int)
          minBar?: (null|int)
          maxBar?: (null|int)
          hoge?: (null|bool)
          fuga?: (null|bool)
        }
      }
    }
  }
}
--- issue2246.cue
{
  issue2246: {
    simplified: {
      #FormFoo: {
        fooID: string
      }
      #FormBar: {
        barID: string
      }
      #Form: {
        (〈1;#FormFoo〉|〈1;#FormBar〉)
      }
      data: {
        fooID: "123"
      }
      out1: (〈0;#Form〉 & 〈0;data〉)
      out2: (〈0;#Form〉 & 〈0;out1〉)
    }
  }
  issue2246: {
    full: {
      data: {
        forms: [
          {
            fooID: "00-0000001"
          },
        ]
      }
      form1040: (〈0;#compute〉 & {
        in: 〈1;data〉
      }).out
      #K1: {
        #_base: {
          common: 3
        }
        #FormFoo: {
          〈1;#_base〉
          fooID: string
        }
        #FormBar: {
          〈1;#_base〉
          barID: string
        }
        #Form: {
          (〈1;#FormFoo〉|〈1;#FormBar〉)
        }
      }
      #Input: {
        forms: [
          ...〈2;#K1〉.#Form,
        ]
      }
      #summarizeReturn: {
        in: 〈1;#Input〉
        out: [
          for _, k in 〈1;in〉.forms {
            〈1;k〉.common
          },
        ]
      }
      #compute: {
        in: 〈1;#Input〉
        out: (〈1;#summarizeReturn〉 & {
          in: 〈1;in〉
        }).out
      }
    }
  }
}
--- issue2263.cue
{
  issue2263: {
    simplified: {
      metrics: 〈0;#Metric〉
      #Metric: {
        (〈1;#IDSource〉|{})
        (〈1;#TargetAverage〉|{})
      }
      metrics: {
        id: "foo"
        avg: 60
      }
      #IDSource: {
        id: string
      }
      #TargetAverage: {
        avg: number
      }
    }
  }
  issue2263: {
    full: {
      metrics: [
        ...〈1;#Metric〉,
      ]
      metrics: [
        {
          id: "foo"
          avg: 60
        },
        {
          id: "bar"
          value: 80
        },
        {
          uri: "baz"
          avg: 70
        },
        {
          uri: "qux"
          value: 90
        },
      ]
      #Metric: {
        〈1;#Source〉
        〈1;#Target〉
      }
      #Source: (〈0;#IDSource〉|〈0;#URISource〉)
      #Target: (〈0;#TargetAverage〉|〈0;#TargetValue〉)
      #IDSource: {
        id: string
      }
      #URISource: {
        uri: string
      }
      #TargetAverage: {
        avg: number
      }
      #TargetValue: {
        value: number
      }
    }
  }
}
--- issue3149.cue
{
  issue3149: {
    #valid: {
      name!: ((=~"^Foo"|"an exception") & (=~"Foo$"|"an exception"))
    }
    list: [
      ...〈1;#valid〉,
    ]
    list: [
      {
        name: "FooBarFoo"
      },
      {
        name: "FooBazFoo"
      },
      {
        name: "FooQuuxFoo"
      },
      {
        name: "an exception"
      },
    ]
  }
}
--- issue3528.cue
{
  issue3528: {
    original: {
      workflows: [
        ...〈1;#Workflow〉,
      ]
      workflows: [
        〈1;test〉,
      ]
      test: (〈0;#Workflow〉 & {})
      #Workflow: {
        container: {
          [string]: (string|〈1;#container〉)
        }
        #container: (string|{
          volumes?: [
            ...string,
          ]
        })
      }
    }
  }
  issue3528: {
    reduced: {
      a?: 〈0;#A〉
      a: (〈0;#A〉 & {})
      #A: {
        A: {
          [string]: (1|〈1;#a〉)
        }
        #a: (2|{
          v: 1
        })
      }
    }
  }
  issue3528: {
    counter: {}
  }
  issue3528: {
    nested: {
      t1: {
        ({
          v: 1
        }|(2|3))
        ({
          v: 1
        }|(2|3))
        ({
          v: 1
        }|(2|3))
        ({
          v: 1
        }|(2|3))
      }
    }
  }
  issue3528: {
    nested: {
      t2: {
        ({
          v: 1
        }|2)
        ({
          v: 1
        }|(2|3))
        ({
          v: 1
        }|2)
        ({
          v: 1
        }|2)
      }
    }
  }
}
--- issue3784.cue
{
  issue3784: {
    reduced: {
      #Schema: {
        a: ({
          kind: "A"
          b: {
            c?: string
          }
          b: {}
        }|{
          kind: "B"
        })
      }
      out: 〈0;#Schema〉
      out: {
        a: {
          kind: "A"
          b: {
            c: "x"
          }
        }
      }
    }
  }
  issue3784: {
    full: {
      #Schema: {
        pages?: {
          build_type?: ("legacy"|"workflow")
          source?: {
            branch?: string
            path?: string
          }
          cname?: string
        }
        pages?: ({
          build_type!: "legacy"
          source!: {
            branch!: _
          }
        }|close({
          build_type!: "workflow"
          cname?: _
        }))
      }
      out: (〈0;#Schema〉 & {
        pages: {
          cname: "foo.com"
          build_type: "legacy"
          source: {
            branch: "main"
            path: "/"
          }
        }
      })
    }
  }
  issue3784: {
    variant1: {
      #Schema: {
        pages: {
          build_type?: ("legacy"|"workflow")
          source: {
            branch?: string
            path?: string
          }
          cname?: string
        }
        pages?: ({
          build_type!: "legacy"
          source!: {
            branch!: _
          }
        }|close({
          build_type!: "workflow"
          cname?: _
        }))
      }
    }
  }
  issue3784: {
    variant2: {
      #Schema: ({
        build_type!: "legacy"
        source!: {
          branch!: _
        }
      }|close({
        build_type!: "workflow"
        cname?: _
      }))
      a: 〈0;#Schema〉
      a: {
        build_type?: ("legacy"|"workflow")
        source: {
          branch?: string
          path?: string
        }
        cname?: string
      }
    }
  }
}
--- issue3958.cue
{
  issue3958: {
    t1: {
      #schema: (int|*1)
      #schema: (int|*3)
      test1: (〈0;#schema〉 & {
        (int|*2)
      })
      test2: (〈0;#schema〉 & {
        (int|*4)
      })
    }
  }
  issue3958: {
    t2: {
      a: ((((int|*4) & (int|*1)) & (int|*3)) & (int|*8))
      b: (((int|*4) & (int|*1)) & (int|*3))
    }
  }
}
--- issue770.cue
{
  issue770: {
    #A: {
      v: ("a"|"b"|"c")
    }
    h: {
      [string]: 〈1;#A〉
    }
    h: {
      a: {
        v: (*"a"|string)
      }
    }
    h: {
      [=~"^b"]: {
        v: (*〈2;h〉.a.v|string)
      }
    }
    h: {
      [=~"^c"]: {
        v: (*〈2;h〉.b.v|string)
      }
    }
    h: {
      b: _
    }
    h: {
      boo: _
    }
    h: {
      c: _
    }
    h: {
      coo: _
    }
  }
}
