-- in.cue --
issue570: {
	results: #DecodeOutput
	results: result: "hello"

	#Output: {
		result: _
	} | {
		error: string
	}

	#DecodeOutput: #Output & {
		result?: [... string]
		...
	}
}

issue516: {
	#Def: {
		match: metrics: string: {}
	} | {}

	x: #Def
	x: match: metrics: "foo": {}
}

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

	if a != "" {
	}
}

issue2916: {
	b: _
	[_]: c:      uint | *1
	[string]: c: >=3 | *3
}
issue3157: {
	foo: *42 | _
	foo: *43 | bool
}
-- issue3581.cue --
issue3581: reduced: {
	list: [...] | *[]
	list: ["\(c)" ]
	c: _
}
-- issue3576.cue --
issue3576: reduced: {
	#A: a!: string
	#B: {
		if false {
			dummy: {}
		}
	}
	foo: #B | #A
	foo: a: "1"
}
issue3576: full: {
	#Run: {
		run!: string
		options?: #Option | [#Option, ...]
		if options != _|_ {
			optionsValue: options
		}
	}

	#Copy: {
		copy!: string
		options?: #Option | [#Option, ...]
		if options != _|_ {
			optionsValue: options
		}
	}
	
	#Option: {}
	
	foo: #Run | #Copy
	foo: run: "make"
}
-- issue3599.cue --
// Ignore errors for irrelevant fields like let and optional fields.
issue3599: full: {
	#Action: {
		action: {
			read!:  string
			write?: _|_
		} | {
			write!: string
			read?:  _|_
		}
	}
	
	#Minio: {
		container: #Action & {
			action: {
				read!:  string
				write?: _|_
			} | {
				write!: string
				read?:  _|_
			}
		}
		doWrite: bool | *true
		container: action: defaultAction
		defaultAction: {
			if doWrite { write: "somefile.txt" }
			if !doWrite { read: "somefile.txt" }
		}
	}
}
issue3599: reduced: p1: {
	{ a?:  1&2 } | { a:  string, b?: 1&2 }
	{  } | {  }
}
issue3599: reduced: p2: {
	{  } | {  }
	{ a?:  1&2 } | { a:  string, b?: 1&2 }
}
issue3599: let: {
	{ } | { a:  B | 1, let B = 1&2 }
	{  } | {  }
}
-- out/eval/stats --
Leaks:  6
Freed:  181
Reused: 171
Allocs: 16
Retain: 34

Unifications: 119
Conjuncts:    268
Disjuncts:    206
-- out/evalalpha --
Errors:
issue516.x: 2 errors in empty disjunction:
issue516.x.match: field not allowed:
    ./in.cue:23:5
issue516.x.match.metrics.foo: field not allowed:
    ./in.cue:23:21
issue570.results.result: conflicting values "hello" and [...string] (mismatched types string and list):
    ./in.cue:3:19
    ./in.cue:12:12

Result:
(_|_){
  // [eval]
  issue570: (_|_){
    // [eval]
    results: (_|_){
      // [eval]
      result: (_|_){
        // [eval] issue570.results.result: conflicting values "hello" and [...string] (mismatched types string and list):
        //     ./in.cue:3:19
        //     ./in.cue:12:12
      }
    }
    #Output: (#struct){ |((#struct){
        result: (_){ _ }
      }, (#struct){
        error: (string){ string }
      }) }
    #DecodeOutput: (#struct){ |((#struct){
        result: (list){
        }
      }, (#struct){
        result?: (_|_){
          // [eval] issue570.#DecodeOutput.result: field not allowed:
          //     ./in.cue:12:3
        }
        error: (string){ string }
      }) }
  }
  issue516: (_|_){
    // [eval]
    #Def: (#struct){ |((#struct){
        match: (#struct){
          metrics: (#struct){
            string: (#struct){
            }
          }
        }
      }, (#struct){
      }) }
    x: (_|_){
      // [eval] issue516.x: 2 errors in empty disjunction:
      // issue516.x.match: field not allowed:
      //     ./in.cue:23:5
      // issue516.x.match.metrics.foo: field not allowed:
      //     ./in.cue:23:21
      match: (struct){
        metrics: (struct){
          foo: (struct){
          }
        }
      }
    }
  }
  explicitDefaultError: (_|_){
    // [incomplete] explicitDefaultError: non-concrete value string in operand to !=:
    //     ./in.cue:30:5
    //     ./in.cue:28:5
    a: (string){ string }
  }
  issue2916: (struct){
    b: (struct){
      c: (int){ |(*(int){ 3 }, (int){ &(>=3, int) }) }
    }
  }
  issue3157: (struct){
    foo: ((bool|int)){ |(*(int){ 43 }, (bool){ bool }) }
  }
  issue3576: (struct){
    reduced: (struct){
      #A: (#struct){
        a!: (string){ string }
      }
      #B: (#struct){
      }
      foo: (#struct){
        a: (string){ "1" }
      }
    }
    full: (struct){
      #Run: (#struct){
        run!: (string){ string }
        options?: ((list|struct)){ |((#struct){
          }, (list){
            0: (#struct){
            }
          }) }
      }
      #Copy: (#struct){
        copy!: (string){ string }
        options?: ((list|struct)){ |((#struct){
          }, (list){
            0: (#struct){
            }
          }) }
      }
      #Option: (#struct){
      }
      foo: (#struct){
        run: (string){ "make" }
        options?: ((list|struct)){ |((#struct){
          }, (list){
            0: (#struct){
            }
          }) }
      }
    }
  }
  issue3581: (struct){
    reduced: (struct){
      list: (_|_){
        // [incomplete] issue3581.reduced.list: 2 errors in empty disjunction:
        // issue3581.reduced.list: incompatible list lengths (0 and 1):
        //     ./issue3581.cue:2:17
        // issue3581.reduced.list.0: invalid interpolation: non-concrete value _ (type _):
        //     ./issue3581.cue:3:9
        0: (_){ _ }
      }
      c: (_){ _ }
    }
  }
  issue3599: (struct){
    full: (struct){
      #Action: (#struct){
        action: (#struct){ |((#struct){
            read!: (string){ string }
            write?: (_|_){
              // [user] explicit error (_|_ literal) in source:
              //     ./issue3599.cue:6:12
            }
          }, (#struct){
            write!: (string){ string }
            read?: (_|_){
              // [user] explicit error (_|_ literal) in source:
              //     ./issue3599.cue:9:12
            }
          }) }
      }
      #Minio: (#struct){
        container: (#struct){
          action: (#struct){
            write: (string){ "somefile.txt" }
            read?: (_|_){
              // [user] explicit error (_|_ literal) in source:
              //     ./issue3599.cue:9:12
              // explicit error (_|_ literal) in source:
              //     ./issue3599.cue:20:13
            }
          }
        }
        doWrite: (bool){ |(*(bool){ true }, (bool){ bool }) }
        defaultAction: (#struct){
          write: (string){ "somefile.txt" }
        }
      }
    }
    reduced: (struct){
      p1: (struct){ |((struct){
          a?: (_|_){
            // [eval] issue3599.reduced.p1.a: conflicting values 2 and 1:
            //     ./issue3599.cue:32:9
            //     ./issue3599.cue:32:11
          }
        }, (struct){
          a: (string){ string }
          b?: (_|_){
            // [eval] issue3599.reduced.p1.b: conflicting values 2 and 1:
            //     ./issue3599.cue:32:35
            //     ./issue3599.cue:32:37
          }
        }) }
      p2: (struct){ |((struct){
          a?: (_|_){
            // [eval] issue3599.reduced.p2.a: conflicting values 2 and 1:
            //     ./issue3599.cue:37:9
            //     ./issue3599.cue:37:11
          }
        }, (struct){
          a: (string){ string }
          b?: (_|_){
            // [eval] issue3599.reduced.p2.b: conflicting values 2 and 1:
            //     ./issue3599.cue:37:35
            //     ./issue3599.cue:37:37
          }
        }) }
    }
    let: (struct){ |((struct){
      }, (struct){
        a: (int){ 1 }
        let B#1 = (_|_){
          // [eval] issue3599.let.B: conflicting values 2 and 1:
          //     ./issue3599.cue:40:29
          //     ./issue3599.cue:40:31
        }
      }) }
  }
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -1,15 +1,10 @@
 Errors:
 issue516.x: 2 errors in empty disjunction:
 issue516.x.match: field not allowed:
-    ./in.cue:20:6
-    ./in.cue:22:5
     ./in.cue:23:5
 issue516.x.match.metrics.foo: field not allowed:
-    ./in.cue:19:19
-    ./in.cue:22:5
     ./in.cue:23:21
 issue570.results.result: conflicting values "hello" and [...string] (mismatched types string and list):
-    ./in.cue:2:11
     ./in.cue:3:19
     ./in.cue:12:12
 
@@ -19,17 +14,12 @@
   issue570: (_|_){
     // [eval]
     results: (_|_){
-      // [eval] issue570.results.result: conflicting values "hello" and [...string] (mismatched types string and list):
-      //     ./in.cue:2:11
-      //     ./in.cue:3:19
-      //     ./in.cue:12:12
+      // [eval]
       result: (_|_){
         // [eval] issue570.results.result: conflicting values "hello" and [...string] (mismatched types string and list):
-        //     ./in.cue:2:11
         //     ./in.cue:3:19
         //     ./in.cue:12:12
       }
-      error: (string){ string }
     }
     #Output: (#struct){ |((#struct){
         result: (_){ _ }
@@ -40,7 +30,9 @@
         result: (list){
         }
       }, (#struct){
-        result?: (list){
+        result?: (_|_){
+          // [eval] issue570.#DecodeOutput.result: field not allowed:
+          //     ./in.cue:12:3
         }
         error: (string){ string }
       }) }
@@ -59,18 +51,10 @@
     x: (_|_){
       // [eval] issue516.x: 2 errors in empty disjunction:
       // issue516.x.match: field not allowed:
-      //     ./in.cue:20:6
-      //     ./in.cue:22:5
       //     ./in.cue:23:5
       // issue516.x.match.metrics.foo: field not allowed:
-      //     ./in.cue:19:19
-      //     ./in.cue:22:5
       //     ./in.cue:23:21
-      match: (_|_){
-        // [eval] issue516.x.match: field not allowed:
-        //     ./in.cue:20:6
-        //     ./in.cue:22:5
-        //     ./in.cue:23:5
+      match: (struct){
         metrics: (struct){
           foo: (struct){
           }
@@ -136,13 +120,11 @@
     reduced: (struct){
       list: (_|_){
         // [incomplete] issue3581.reduced.list: 2 errors in empty disjunction:
-        // issue3581.reduced.list: incompatible list lengths (0 and 1)
+        // issue3581.reduced.list: incompatible list lengths (0 and 1):
+        //     ./issue3581.cue:2:17
         // issue3581.reduced.list.0: invalid interpolation: non-concrete value _ (type _):
         //     ./issue3581.cue:3:9
-        0: (_|_){
-          // [incomplete] issue3581.reduced.list.0: invalid interpolation: non-concrete value _ (type _):
-          //     ./issue3581.cue:3:9
-        }
+        0: (_){ _ }
       }
       c: (_){ _ }
     }
@@ -186,7 +168,6 @@
       p1: (struct){ |((struct){
           a?: (_|_){
             // [eval] issue3599.reduced.p1.a: conflicting values 2 and 1:
-            //     ./issue3599.cue:32:2
             //     ./issue3599.cue:32:9
             //     ./issue3599.cue:32:11
           }
@@ -194,7 +175,6 @@
           a: (string){ string }
           b?: (_|_){
             // [eval] issue3599.reduced.p1.b: conflicting values 2 and 1:
-            //     ./issue3599.cue:32:2
             //     ./issue3599.cue:32:35
             //     ./issue3599.cue:32:37
           }
@@ -202,7 +182,6 @@
       p2: (struct){ |((struct){
           a?: (_|_){
             // [eval] issue3599.reduced.p2.a: conflicting values 2 and 1:
-            //     ./issue3599.cue:37:2
             //     ./issue3599.cue:37:9
             //     ./issue3599.cue:37:11
           }
@@ -210,7 +189,6 @@
           a: (string){ string }
           b?: (_|_){
             // [eval] issue3599.reduced.p2.b: conflicting values 2 and 1:
-            //     ./issue3599.cue:37:2
             //     ./issue3599.cue:37:35
             //     ./issue3599.cue:37:37
           }
@@ -221,7 +199,6 @@
         a: (int){ 1 }
         let B#1 = (_|_){
           // [eval] issue3599.let.B: conflicting values 2 and 1:
-          //     ./issue3599.cue:40:2
           //     ./issue3599.cue:40:29
           //     ./issue3599.cue:40:31
         }
-- diff/todo/p3 --
Missing error positions.
-- diff/explanation --
The additional "field not allowed" error is correct and a message corresponding
to one of the conjuncts failing.
issue516.x.match: changes are okay and arguably better.
-- out/eval --
Errors:
issue516.x: 2 errors in empty disjunction:
issue516.x.match: field not allowed:
    ./in.cue:20:6
    ./in.cue:22:5
    ./in.cue:23:5
issue516.x.match.metrics.foo: field not allowed:
    ./in.cue:19:19
    ./in.cue:22:5
    ./in.cue:23:21
issue570.results.result: conflicting values "hello" and [...string] (mismatched types string and list):
    ./in.cue:2:11
    ./in.cue:3:19
    ./in.cue:12:12

Result:
(_|_){
  // [eval]
  issue570: (_|_){
    // [eval]
    results: (_|_){
      // [eval] issue570.results.result: conflicting values "hello" and [...string] (mismatched types string and list):
      //     ./in.cue:2:11
      //     ./in.cue:3:19
      //     ./in.cue:12:12
      result: (_|_){
        // [eval] issue570.results.result: conflicting values "hello" and [...string] (mismatched types string and list):
        //     ./in.cue:2:11
        //     ./in.cue:3:19
        //     ./in.cue:12:12
      }
      error: (string){ string }
    }
    #Output: (#struct){ |((#struct){
        result: (_){ _ }
      }, (#struct){
        error: (string){ string }
      }) }
    #DecodeOutput: (#struct){ |((#struct){
        result: (list){
        }
      }, (#struct){
        result?: (list){
        }
        error: (string){ string }
      }) }
  }
  issue516: (_|_){
    // [eval]
    #Def: (#struct){ |((#struct){
        match: (#struct){
          metrics: (#struct){
            string: (#struct){
            }
          }
        }
      }, (#struct){
      }) }
    x: (_|_){
      // [eval] issue516.x: 2 errors in empty disjunction:
      // issue516.x.match: field not allowed:
      //     ./in.cue:20:6
      //     ./in.cue:22:5
      //     ./in.cue:23:5
      // issue516.x.match.metrics.foo: field not allowed:
      //     ./in.cue:19:19
      //     ./in.cue:22:5
      //     ./in.cue:23:21
      match: (_|_){
        // [eval] issue516.x.match: field not allowed:
        //     ./in.cue:20:6
        //     ./in.cue:22:5
        //     ./in.cue:23:5
        metrics: (struct){
          foo: (struct){
          }
        }
      }
    }
  }
  explicitDefaultError: (_|_){
    // [incomplete] explicitDefaultError: non-concrete value string in operand to !=:
    //     ./in.cue:30:5
    //     ./in.cue:28:5
    a: (string){ string }
  }
  issue2916: (struct){
    b: (struct){
      c: (int){ |(*(int){ 3 }, (int){ &(>=3, int) }) }
    }
  }
  issue3157: (struct){
    foo: ((bool|int)){ |(*(int){ 43 }, (bool){ bool }) }
  }
  issue3576: (struct){
    reduced: (struct){
      #A: (#struct){
        a!: (string){ string }
      }
      #B: (#struct){
      }
      foo: (#struct){
        a: (string){ "1" }
      }
    }
    full: (struct){
      #Run: (#struct){
        run!: (string){ string }
        options?: ((list|struct)){ |((#struct){
          }, (list){
            0: (#struct){
            }
          }) }
      }
      #Copy: (#struct){
        copy!: (string){ string }
        options?: ((list|struct)){ |((#struct){
          }, (list){
            0: (#struct){
            }
          }) }
      }
      #Option: (#struct){
      }
      foo: (#struct){
        run: (string){ "make" }
        options?: ((list|struct)){ |((#struct){
          }, (list){
            0: (#struct){
            }
          }) }
      }
    }
  }
  issue3581: (struct){
    reduced: (struct){
      list: (_|_){
        // [incomplete] issue3581.reduced.list: 2 errors in empty disjunction:
        // issue3581.reduced.list: incompatible list lengths (0 and 1)
        // issue3581.reduced.list.0: invalid interpolation: non-concrete value _ (type _):
        //     ./issue3581.cue:3:9
        0: (_|_){
          // [incomplete] issue3581.reduced.list.0: invalid interpolation: non-concrete value _ (type _):
          //     ./issue3581.cue:3:9
        }
      }
      c: (_){ _ }
    }
  }
  issue3599: (struct){
    full: (struct){
      #Action: (#struct){
        action: (#struct){ |((#struct){
            read!: (string){ string }
            write?: (_|_){
              // [user] explicit error (_|_ literal) in source:
              //     ./issue3599.cue:6:12
            }
          }, (#struct){
            write!: (string){ string }
            read?: (_|_){
              // [user] explicit error (_|_ literal) in source:
              //     ./issue3599.cue:9:12
            }
          }) }
      }
      #Minio: (#struct){
        container: (#struct){
          action: (#struct){
            write: (string){ "somefile.txt" }
            read?: (_|_){
              // [user] explicit error (_|_ literal) in source:
              //     ./issue3599.cue:9:12
              // explicit error (_|_ literal) in source:
              //     ./issue3599.cue:20:13
            }
          }
        }
        doWrite: (bool){ |(*(bool){ true }, (bool){ bool }) }
        defaultAction: (#struct){
          write: (string){ "somefile.txt" }
        }
      }
    }
    reduced: (struct){
      p1: (struct){ |((struct){
          a?: (_|_){
            // [eval] issue3599.reduced.p1.a: conflicting values 2 and 1:
            //     ./issue3599.cue:32:2
            //     ./issue3599.cue:32:9
            //     ./issue3599.cue:32:11
          }
        }, (struct){
          a: (string){ string }
          b?: (_|_){
            // [eval] issue3599.reduced.p1.b: conflicting values 2 and 1:
            //     ./issue3599.cue:32:2
            //     ./issue3599.cue:32:35
            //     ./issue3599.cue:32:37
          }
        }) }
      p2: (struct){ |((struct){
          a?: (_|_){
            // [eval] issue3599.reduced.p2.a: conflicting values 2 and 1:
            //     ./issue3599.cue:37:2
            //     ./issue3599.cue:37:9
            //     ./issue3599.cue:37:11
          }
        }, (struct){
          a: (string){ string }
          b?: (_|_){
            // [eval] issue3599.reduced.p2.b: conflicting values 2 and 1:
            //     ./issue3599.cue:37:2
            //     ./issue3599.cue:37:35
            //     ./issue3599.cue:37:37
          }
        }) }
    }
    let: (struct){ |((struct){
      }, (struct){
        a: (int){ 1 }
        let B#1 = (_|_){
          // [eval] issue3599.let.B: conflicting values 2 and 1:
          //     ./issue3599.cue:40:2
          //     ./issue3599.cue:40:29
          //     ./issue3599.cue:40:31
        }
      }) }
  }
}
-- out/compile --
--- in.cue
{
  issue570: {
    results: 〈0;#DecodeOutput〉
    results: {
      result: "hello"
    }
    #Output: ({
      result: _
    }|{
      error: string
    })
    #DecodeOutput: (〈0;#Output〉 & {
      result?: [
        ...string,
      ]
      ...
    })
  }
  issue516: {
    #Def: ({
      match: {
        metrics: {
          string: {}
        }
      }
    }|{})
    x: 〈0;#Def〉
    x: {
      match: {
        metrics: {
          foo: {}
        }
      }
    }
  }
  explicitDefaultError: {
    a: (string|*_|_(explicit error (_|_ literal) in source))
    if (〈0;a〉 != "") {}
  }
  issue2916: {
    b: _
    [_]: {
      c: (&(int, >=0)|*1)
    }
    [string]: {
      c: (>=3|*3)
    }
  }
  issue3157: {
    foo: (*42|_)
    foo: (*43|bool)
  }
}
--- issue3576.cue
{
  issue3576: {
    reduced: {
      #A: {
        a!: string
      }
      #B: {
        if false {
          dummy: {}
        }
      }
      foo: (〈0;#B〉|〈0;#A〉)
      foo: {
        a: "1"
      }
    }
  }
  issue3576: {
    full: {
      #Run: {
        run!: string
        options?: (〈1;#Option〉|[
          〈2;#Option〉,
          ...,
        ])
        if (〈0;options〉 != _|_(explicit error (_|_ literal) in source)) {
          optionsValue: 〈1;options〉
        }
      }
      #Copy: {
        copy!: string
        options?: (〈1;#Option〉|[
          〈2;#Option〉,
          ...,
        ])
        if (〈0;options〉 != _|_(explicit error (_|_ literal) in source)) {
          optionsValue: 〈1;options〉
        }
      }
      #Option: {}
      foo: (〈0;#Run〉|〈0;#Copy〉)
      foo: {
        run: "make"
      }
    }
  }
}
--- issue3581.cue
{
  issue3581: {
    reduced: {
      list: ([
        ...,
      ]|*[])
      list: [
        "\(〈1;c〉)",
      ]
      c: _
    }
  }
}
--- issue3599.cue
{
  issue3599: {
    full: {
      #Action: {
        action: ({
          read!: string
          write?: _|_(explicit error (_|_ literal) in source)
        }|{
          write!: string
          read?: _|_(explicit error (_|_ literal) in source)
        })
      }
      #Minio: {
        container: (〈1;#Action〉 & {
          action: ({
            read!: string
            write?: _|_(explicit error (_|_ literal) in source)
          }|{
            write!: string
            read?: _|_(explicit error (_|_ literal) in source)
          })
        })
        doWrite: (bool|*true)
        container: {
          action: 〈1;defaultAction〉
        }
        defaultAction: {
          if 〈1;doWrite〉 {
            write: "somefile.txt"
          }
          if !〈1;doWrite〉 {
            read: "somefile.txt"
          }
        }
      }
    }
  }
  issue3599: {
    reduced: {
      p1: {
        ({
          a?: (1 & 2)
        }|{
          a: string
          b?: (1 & 2)
        })
        ({}|{})
      }
    }
  }
  issue3599: {
    reduced: {
      p2: {
        ({}|{})
        ({
          a?: (1 & 2)
        }|{
          a: string
          b?: (1 & 2)
        })
      }
    }
  }
  issue3599: {
    let: {
      ({}|{
        a: (〈0;let B#1〉|1)
        let B#1 = (1 & 2)
      })
      ({}|{})
    }
  }
}
