-- in.cue --
// expose at top level
X: {
	_a: foo: true
	_a: _ | close({y!: z?: _})
	_b: _a & {y: {}}
	concrete: _b.y
	isTrue: concrete != _|_
}
{X}

sub: t1: {
	X: {
		_a: foo: true
		_a: _ | close({y!: z?: _})
		_b: _a & {y: {}}
		concrete: _b.y
	}
	{X}
}
sub: t2: {
	X: {
		_a: foo: true
		_a: _ | close({y!: z?: _})
		_b: _a & {y: {}}
		concrete: _b.y
	}
	X
}
sub: t3: {
	#X: {
		_a: foo: true
		_a: _ | close({y!: z?: _})
		_b: _a & {y: {}}
		concrete: _b.y
	}
	{#X}
}
sub: t4: {
	#X: {
		_a: foo: true
		_a: _ | close({y!: z?: _})
		_b: _a & {y: {}}
		concrete: _b.y
	}
	#X
}

full: {
	#Foo: {
		_data: Foo: true
		_data: _ | close({Extra!: optional?: _})

		_dataWithExtra: _data & {Extra: {}}

		out: _dataWithExtra.Extra != _|_
	}

	{#Foo}
}
-- out/evalalpha/stats --
Leaks:  339
Freed:  0
Reused: 0
Allocs: 339
Retain: 0

Unifications: 171
Conjuncts:    322
Disjuncts:    48

CloseIDElems: 1109
NumCloseIDs: 88
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
diff old new
--- old
+++ new
@@ -1,9 +1,12 @@
-Leaks:  24
-Freed:  207
-Reused: 200
-Allocs: 31
-Retain: 30
-
-Unifications: 183
-Conjuncts:    344
-Disjuncts:    237
+Leaks:  339
+Freed:  0
+Reused: 0
+Allocs: 339
+Retain: 0
+
+Unifications: 171
+Conjuncts:    322
+Disjuncts:    48
+
+CloseIDElems: 1109
+NumCloseIDs: 88
-- out/eval/stats --
Leaks:  24
Freed:  207
Reused: 200
Allocs: 31
Retain: 30

Unifications: 183
Conjuncts:    344
Disjuncts:    237
-- out/evalalpha --
(struct){
  X: (struct){
    _a: (struct){
      foo: (bool){ true }
    }
    _b: (struct){
      y: (struct){
      }
      foo: (bool){ true }
    }
    concrete: (struct){
    }
    isTrue: (bool){ true }
  }
  sub: (struct){
    t1: (struct){
      X: (struct){
        _a: (struct){
          foo: (bool){ true }
        }
        _b: (struct){
          y: (struct){
          }
          foo: (bool){ true }
        }
        concrete: (struct){
        }
      }
      _a: (struct){
        foo: (bool){ true }
      }
      _b: (struct){
        y: (struct){
        }
        foo: (bool){ true }
      }
      concrete: (struct){
      }
    }
    t2: (struct){
      X: (struct){
        _a: (struct){
          foo: (bool){ true }
        }
        _b: (struct){
          y: (struct){
          }
          foo: (bool){ true }
        }
        concrete: (struct){
        }
      }
      _a: (struct){
        foo: (bool){ true }
      }
      _b: (struct){
        y: (struct){
        }
        foo: (bool){ true }
      }
      concrete: (struct){
      }
    }
    t3: (#struct){
      #X: (#struct){
        _a: (#struct){
          foo: (bool){ true }
        }
        _b: (#struct){
          y: (#struct){
          }
          foo: (bool){ true }
        }
        concrete: (#struct){
        }
      }
      _a: (#struct){
        foo: (bool){ true }
      }
      _b: (#struct){
        y: (#struct){
        }
        foo: (bool){ true }
      }
      concrete: (#struct){
      }
    }
    t4: (#struct){
      #X: (#struct){
        _a: (#struct){
          foo: (bool){ true }
        }
        _b: (#struct){
          y: (#struct){
          }
          foo: (bool){ true }
        }
        concrete: (#struct){
        }
      }
      _a: (#struct){
        foo: (bool){ true }
      }
      _b: (#struct){
        y: (#struct){
        }
        foo: (bool){ true }
      }
      concrete: (#struct){
      }
    }
  }
  full: (#struct){
    #Foo: (#struct){
      _data: (#struct){
        Foo: (bool){ true }
      }
      _dataWithExtra: (#struct){
        Extra: (#struct){
        }
        Foo: (bool){ true }
      }
      out: (bool){ true }
    }
    _data: (#struct){
      Foo: (bool){ true }
    }
    _dataWithExtra: (#struct){
      Extra: (#struct){
      }
      Foo: (bool){ true }
    }
    out: (bool){ true }
  }
  _a: (struct){
    foo: (bool){ true }
  }
  _b: (struct){
    y: (struct){
    }
    foo: (bool){ true }
  }
  concrete: (struct){
  }
  isTrue: (bool){ true }
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -4,25 +4,14 @@
       foo: (bool){ true }
     }
     _b: (struct){
-      foo: (bool){ true }
       y: (struct){
       }
+      foo: (bool){ true }
     }
     concrete: (struct){
     }
     isTrue: (bool){ true }
   }
-  _a: (struct){
-    foo: (bool){ true }
-  }
-  _b: (struct){
-    foo: (bool){ true }
-    y: (struct){
-    }
-  }
-  concrete: (struct){
-  }
-  isTrue: (bool){ true }
   sub: (struct){
     t1: (struct){
       X: (struct){
@@ -30,20 +19,20 @@
           foo: (bool){ true }
         }
         _b: (struct){
-          foo: (bool){ true }
-          y: (struct){
-          }
-        }
-        concrete: (struct){
-        }
-      }
-      _a: (struct){
-        foo: (bool){ true }
-      }
-      _b: (struct){
-        foo: (bool){ true }
-        y: (struct){
-        }
+          y: (struct){
+          }
+          foo: (bool){ true }
+        }
+        concrete: (struct){
+        }
+      }
+      _a: (struct){
+        foo: (bool){ true }
+      }
+      _b: (struct){
+        y: (struct){
+        }
+        foo: (bool){ true }
       }
       concrete: (struct){
       }
@@ -54,20 +43,20 @@
           foo: (bool){ true }
         }
         _b: (struct){
-          foo: (bool){ true }
-          y: (struct){
-          }
-        }
-        concrete: (struct){
-        }
-      }
-      _a: (struct){
-        foo: (bool){ true }
-      }
-      _b: (struct){
-        foo: (bool){ true }
-        y: (struct){
-        }
+          y: (struct){
+          }
+          foo: (bool){ true }
+        }
+        concrete: (struct){
+        }
+      }
+      _a: (struct){
+        foo: (bool){ true }
+      }
+      _b: (struct){
+        y: (struct){
+        }
+        foo: (bool){ true }
       }
       concrete: (struct){
       }
@@ -78,20 +67,20 @@
           foo: (bool){ true }
         }
         _b: (#struct){
-          foo: (bool){ true }
-          y: (#struct){
-          }
-        }
-        concrete: (#struct){
-        }
-      }
-      _a: (#struct){
-        foo: (bool){ true }
-      }
-      _b: (#struct){
-        foo: (bool){ true }
-        y: (#struct){
-        }
+          y: (#struct){
+          }
+          foo: (bool){ true }
+        }
+        concrete: (#struct){
+        }
+      }
+      _a: (#struct){
+        foo: (bool){ true }
+      }
+      _b: (#struct){
+        y: (#struct){
+        }
+        foo: (bool){ true }
       }
       concrete: (#struct){
       }
@@ -102,20 +91,20 @@
           foo: (bool){ true }
         }
         _b: (#struct){
-          foo: (bool){ true }
-          y: (#struct){
-          }
-        }
-        concrete: (#struct){
-        }
-      }
-      _a: (#struct){
-        foo: (bool){ true }
-      }
-      _b: (#struct){
-        foo: (bool){ true }
-        y: (#struct){
-        }
+          y: (#struct){
+          }
+          foo: (bool){ true }
+        }
+        concrete: (#struct){
+        }
+      }
+      _a: (#struct){
+        foo: (bool){ true }
+      }
+      _b: (#struct){
+        y: (#struct){
+        }
+        foo: (bool){ true }
       }
       concrete: (#struct){
       }
@@ -127,9 +116,9 @@
         Foo: (bool){ true }
       }
       _dataWithExtra: (#struct){
-        Foo: (bool){ true }
         Extra: (#struct){
         }
+        Foo: (bool){ true }
       }
       out: (bool){ true }
     }
@@ -137,10 +126,21 @@
       Foo: (bool){ true }
     }
     _dataWithExtra: (#struct){
-      Foo: (bool){ true }
       Extra: (#struct){
       }
+      Foo: (bool){ true }
     }
     out: (bool){ true }
   }
+  _a: (struct){
+    foo: (bool){ true }
+  }
+  _b: (struct){
+    y: (struct){
+    }
+    foo: (bool){ true }
+  }
+  concrete: (struct){
+  }
+  isTrue: (bool){ true }
 }
-- out/eval --
(struct){
  X: (struct){
    _a: (struct){
      foo: (bool){ true }
    }
    _b: (struct){
      foo: (bool){ true }
      y: (struct){
      }
    }
    concrete: (struct){
    }
    isTrue: (bool){ true }
  }
  _a: (struct){
    foo: (bool){ true }
  }
  _b: (struct){
    foo: (bool){ true }
    y: (struct){
    }
  }
  concrete: (struct){
  }
  isTrue: (bool){ true }
  sub: (struct){
    t1: (struct){
      X: (struct){
        _a: (struct){
          foo: (bool){ true }
        }
        _b: (struct){
          foo: (bool){ true }
          y: (struct){
          }
        }
        concrete: (struct){
        }
      }
      _a: (struct){
        foo: (bool){ true }
      }
      _b: (struct){
        foo: (bool){ true }
        y: (struct){
        }
      }
      concrete: (struct){
      }
    }
    t2: (struct){
      X: (struct){
        _a: (struct){
          foo: (bool){ true }
        }
        _b: (struct){
          foo: (bool){ true }
          y: (struct){
          }
        }
        concrete: (struct){
        }
      }
      _a: (struct){
        foo: (bool){ true }
      }
      _b: (struct){
        foo: (bool){ true }
        y: (struct){
        }
      }
      concrete: (struct){
      }
    }
    t3: (#struct){
      #X: (#struct){
        _a: (#struct){
          foo: (bool){ true }
        }
        _b: (#struct){
          foo: (bool){ true }
          y: (#struct){
          }
        }
        concrete: (#struct){
        }
      }
      _a: (#struct){
        foo: (bool){ true }
      }
      _b: (#struct){
        foo: (bool){ true }
        y: (#struct){
        }
      }
      concrete: (#struct){
      }
    }
    t4: (#struct){
      #X: (#struct){
        _a: (#struct){
          foo: (bool){ true }
        }
        _b: (#struct){
          foo: (bool){ true }
          y: (#struct){
          }
        }
        concrete: (#struct){
        }
      }
      _a: (#struct){
        foo: (bool){ true }
      }
      _b: (#struct){
        foo: (bool){ true }
        y: (#struct){
        }
      }
      concrete: (#struct){
      }
    }
  }
  full: (#struct){
    #Foo: (#struct){
      _data: (#struct){
        Foo: (bool){ true }
      }
      _dataWithExtra: (#struct){
        Foo: (bool){ true }
        Extra: (#struct){
        }
      }
      out: (bool){ true }
    }
    _data: (#struct){
      Foo: (bool){ true }
    }
    _dataWithExtra: (#struct){
      Foo: (bool){ true }
      Extra: (#struct){
      }
    }
    out: (bool){ true }
  }
}
-- out/compile --
--- in.cue
{
  X: {
    _a: {
      foo: true
    }
    _a: (_|close({
      y!: {
        z?: _
      }
    }))
    _b: (〈0;_a〉 & {
      y: {}
    })
    concrete: 〈0;_b〉.y
    isTrue: (〈0;concrete〉 != _|_(explicit error (_|_ literal) in source))
  }
  {
    〈1;X〉
  }
  sub: {
    t1: {
      X: {
        _a: {
          foo: true
        }
        _a: (_|close({
          y!: {
            z?: _
          }
        }))
        _b: (〈0;_a〉 & {
          y: {}
        })
        concrete: 〈0;_b〉.y
      }
      {
        〈1;X〉
      }
    }
  }
  sub: {
    t2: {
      X: {
        _a: {
          foo: true
        }
        _a: (_|close({
          y!: {
            z?: _
          }
        }))
        _b: (〈0;_a〉 & {
          y: {}
        })
        concrete: 〈0;_b〉.y
      }
      〈0;X〉
    }
  }
  sub: {
    t3: {
      #X: {
        _a: {
          foo: true
        }
        _a: (_|close({
          y!: {
            z?: _
          }
        }))
        _b: (〈0;_a〉 & {
          y: {}
        })
        concrete: 〈0;_b〉.y
      }
      {
        〈1;#X〉
      }
    }
  }
  sub: {
    t4: {
      #X: {
        _a: {
          foo: true
        }
        _a: (_|close({
          y!: {
            z?: _
          }
        }))
        _b: (〈0;_a〉 & {
          y: {}
        })
        concrete: 〈0;_b〉.y
      }
      〈0;#X〉
    }
  }
  full: {
    #Foo: {
      _data: {
        Foo: true
      }
      _data: (_|close({
        Extra!: {
          optional?: _
        }
      }))
      _dataWithExtra: (〈0;_data〉 & {
        Extra: {}
      })
      out: (〈0;_dataWithExtra〉.Extra != _|_(explicit error (_|_ literal) in source))
    }
    {
      〈1;#Foo〉
    }
  }
}
