#name: definitions with disjunctions
#evalPartial
-- in.cue --
#Foo: {
	field: int

	{a: 1} |
	{b: 2}
}

foo: #Foo
foo: {a: 1}

bar: #Foo
bar: {c: 2}

baz: #Foo
baz: {b: 2}
-- out/def --
#Foo: {
	field: int
	a:     1
} | {
	field: int
	b:     2
}
foo: #Foo & {
	a: 1
}
bar: _|_ // 
baz: #Foo & {
	b: 2
}
-- out/legacy-debug --
<0>{#Foo: (<1>C{field: int, a: 1} | <2>C{field: int, b: 2}), foo: <3>C{field: int, a: 1}, bar: _|_(2:empty disjunction: field "c" not allowed in closed struct), baz: <4>C{field: int, b: 2}}
-- out/compile --
--- in.cue
{
  #Foo: {
    field: int
    ({
      a: 1
    }|{
      b: 2
    })
  }
  foo: 〈0;#Foo〉
  foo: {
    a: 1
  }
  bar: 〈0;#Foo〉
  bar: {
    c: 2
  }
  baz: 〈0;#Foo〉
  baz: {
    b: 2
  }
}
-- out/eval/stats --
Leaks:  0
Freed:  33
Reused: 28
Allocs: 5
Retain: 0

Unifications: 25
Conjuncts:    45
Disjuncts:    33
-- out/evalalpha --
Errors:
bar.c: field not allowed:
    ./in.cue:12:7

Result:
(_|_){
  // [eval]
  #Foo: (#struct){ |((#struct){
      field: (int){ int }
      a: (int){ 1 }
    }, (#struct){
      field: (int){ int }
      b: (int){ 2 }
    }) }
  foo: (#struct){
    a: (int){ 1 }
    field: (int){ int }
  }
  bar: (_|_){
    // [eval] bar.c: field not allowed:
    //     ./in.cue:12:7
    c: (int){ 2 }
    field: (int){ int }
  }
  baz: (#struct){
    b: (int){ 2 }
    field: (int){ int }
  }
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -1,8 +1,5 @@
 Errors:
 bar.c: field not allowed:
-    ./in.cue:1:7
-    ./in.cue:4:2
-    ./in.cue:11:6
     ./in.cue:12:7
 
 Result:
@@ -16,28 +13,17 @@
       b: (int){ 2 }
     }) }
   foo: (#struct){
-    field: (int){ int }
     a: (int){ 1 }
+    field: (int){ int }
   }
   bar: (_|_){
     // [eval] bar.c: field not allowed:
-    //     ./in.cue:1:7
-    //     ./in.cue:4:2
-    //     ./in.cue:11:6
     //     ./in.cue:12:7
-    field: (int){ int }
-    c: (_|_){
-      // [eval] bar.c: field not allowed:
-      //     ./in.cue:1:7
-      //     ./in.cue:4:2
-      //     ./in.cue:5:2
-      //     ./in.cue:11:6
-      //     ./in.cue:12:7
-    }
-    b: (int){ 2 }
+    c: (int){ 2 }
+    field: (int){ int }
   }
   baz: (#struct){
-    field: (int){ int }
-    b: (int){ 2 }
+    b: (int){ 2 }
+    field: (int){ int }
   }
 }
-- diff/todo/p2 --
Missing error positions and reorderings.
-- diff/explanation --
bar.b: removed in new evaluator. This is correct. In the old
evaluator this addition was spurious.
-- out/eval --
Errors:
bar.c: field not allowed:
    ./in.cue:1:7
    ./in.cue:4:2
    ./in.cue:11:6
    ./in.cue:12:7

Result:
(_|_){
  // [eval]
  #Foo: (#struct){ |((#struct){
      field: (int){ int }
      a: (int){ 1 }
    }, (#struct){
      field: (int){ int }
      b: (int){ 2 }
    }) }
  foo: (#struct){
    field: (int){ int }
    a: (int){ 1 }
  }
  bar: (_|_){
    // [eval] bar.c: field not allowed:
    //     ./in.cue:1:7
    //     ./in.cue:4:2
    //     ./in.cue:11:6
    //     ./in.cue:12:7
    field: (int){ int }
    c: (_|_){
      // [eval] bar.c: field not allowed:
      //     ./in.cue:1:7
      //     ./in.cue:4:2
      //     ./in.cue:5:2
      //     ./in.cue:11:6
      //     ./in.cue:12:7
    }
    b: (int){ 2 }
  }
  baz: (#struct){
    field: (int){ int }
    b: (int){ 2 }
  }
}
