-- in.cue --
s: string

e1:  s + s
e2:  >"bar" & s // okay
e3:  >s & "foo" // not okay
e3b: >s

e4: >e1 & s
e5: <e5 & s

E: {
	a: c - b
	b: c - a
	c: a+b & >=5
}

a:    int
okay: (>10 & <a) + 3

issue1837: {
	// x is properly recognized as erroneous and the "message" field is added
	// with the value "a", instead of as a cycle error.
	p1: {
		context: {}
		x: context.b // incomplete error
		if x == _|_ {
			message: "a"
		}
	}
	p2: {
		if x == _|_ {
			message: "a"
		}
		x: context.b // incomplete error
		context: {}
	}
	p3: {
		if x == _|_ {
			message: "a"
		}
		context: {}
		x: context.b // incomplete error
	}
}
-- out/evalalpha/stats --
Leaks:  28
Freed:  0
Reused: 0
Allocs: 28
Retain: 0

Unifications: 28
Conjuncts:    40
Disjuncts:    0

CloseIDElems: 0
NumCloseIDs: 6
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
diff old new
--- old
+++ new
@@ -1,9 +1,12 @@
-Leaks:  2
-Freed:  30
-Reused: 25
-Allocs: 7
-Retain: 80
-
-Unifications: 32
-Conjuncts:    156
-Disjuncts:    29
+Leaks:  28
+Freed:  0
+Reused: 0
+Allocs: 28
+Retain: 0
+
+Unifications: 28
+Conjuncts:    40
+Disjuncts:    0
+
+CloseIDElems: 0
+NumCloseIDs: 6
-- out/eval/stats --
Leaks:  2
Freed:  30
Reused: 25
Allocs: 7
Retain: 80

Unifications: 32
Conjuncts:    156
Disjuncts:    29
-- out/eval --
(struct){
  s: (string){ string }
  e1: (_|_){
    // [incomplete] e1: non-concrete value string in operand to +:
    //     ./in.cue:3:6
    //     ./in.cue:1:4
  }
  e2: (string){ >"bar" }
  e3: (_|_){
    // [incomplete] e3: non-concrete value s for bound >:
    //     ./in.cue:5:7
  }
  e3b: (_|_){
    // [incomplete] e3b: non-concrete value s for bound >:
    //     ./in.cue:6:7
  }
  e4: (_|_){
    // [incomplete] e1: non-concrete value string in operand to +:
    //     ./in.cue:3:6
    //     ./in.cue:1:4
  }
  e5: (_|_){
    // [cycle] cycle error
  }
  E: (struct){
    a: (_|_){
      // [cycle] cycle error:
      //     ./in.cue:12:5
    }
    b: (_|_){
      // [cycle] cycle error:
      //     ./in.cue:13:5
    }
    c: (_|_){
      // [cycle] cycle error:
      //     ./in.cue:12:5
      // cycle error:
      //     ./in.cue:13:5
    }
  }
  a: (int){ int }
  okay: (_|_){
    // [incomplete] non-concrete value a for bound <:
    //     ./in.cue:18:15
  }
  issue1837: (struct){
    p1: (struct){
      context: (struct){
      }
      x: (_|_){
        // [incomplete] issue1837.p1.x: undefined field: b:
        //     ./in.cue:25:14
      }
      message: (string){ "a" }
    }
    p2: (struct){
      message: (string){ "a" }
      x: (_|_){
        // [incomplete] issue1837.p2.x: undefined field: b:
        //     ./in.cue:34:14
      }
      context: (struct){
      }
    }
    p3: (struct){
      message: (string){ "a" }
      context: (struct){
      }
      x: (_|_){
        // [incomplete] issue1837.p3.x: undefined field: b:
        //     ./in.cue:42:14
      }
    }
  }
}
-- out/evalalpha --
(struct){
  s: (string){ string }
  e1: (_|_){
    // [incomplete] e1: non-concrete value string in operand to +:
    //     ./in.cue:3:6
    //     ./in.cue:1:4
  }
  e2: (string){ >"bar" }
  e3: (_|_){
    // [incomplete] e3: non-concrete value s for bound >:
    //     ./in.cue:5:7
  }
  e3b: (_|_){
    // [incomplete] e3b: non-concrete value s for bound >:
    //     ./in.cue:6:7
  }
  e4: (_|_){
    // [incomplete] e1: non-concrete value string in operand to +:
    //     ./in.cue:3:6
    //     ./in.cue:1:4
  }
  e5: (_|_){
    // [incomplete] e5: non-concrete value e5 for bound <:
    //     ./in.cue:9:6
  }
  E: (struct){
    a: (_|_){
      // [incomplete] E.a: non-concrete value >=5 in operand to -:
      //     ./in.cue:12:5
      //     ./in.cue:14:5
      //     ./in.cue:14:11
      // E.b: non-concrete value >=5 in operand to -:
      //     ./in.cue:13:5
      //     ./in.cue:14:5
      //     ./in.cue:14:11
    }
    b: (_|_){
      // [incomplete] E.b: non-concrete value >=5 in operand to -:
      //     ./in.cue:13:5
      //     ./in.cue:14:5
      //     ./in.cue:14:11
    }
    c: (_|_){
      // [incomplete] E.b: non-concrete value >=5 in operand to -:
      //     ./in.cue:13:5
      //     ./in.cue:14:5
      //     ./in.cue:14:11
    }
  }
  a: (int){ int }
  okay: (_|_){
    // [incomplete] non-concrete value a for bound <:
    //     ./in.cue:18:15
  }
  issue1837: (struct){
    p1: (struct){
      context: (struct){
      }
      x: (_|_){
        // [incomplete] issue1837.p1.x: undefined field: b:
        //     ./in.cue:25:14
      }
      message: (string){ "a" }
    }
    p2: (struct){
      message: (string){ "a" }
      x: (_|_){
        // [incomplete] issue1837.p2.x: undefined field: b:
        //     ./in.cue:34:14
      }
      context: (struct){
      }
    }
    p3: (struct){
      message: (string){ "a" }
      context: (struct){
      }
      x: (_|_){
        // [incomplete] issue1837.p3.x: undefined field: b:
        //     ./in.cue:42:14
      }
    }
  }
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -20,22 +20,31 @@
     //     ./in.cue:1:4
   }
   e5: (_|_){
-    // [cycle] cycle error
+    // [incomplete] e5: non-concrete value e5 for bound <:
+    //     ./in.cue:9:6
   }
   E: (struct){
     a: (_|_){
-      // [cycle] cycle error:
-      //     ./in.cue:12:5
+      // [incomplete] E.a: non-concrete value >=5 in operand to -:
+      //     ./in.cue:12:5
+      //     ./in.cue:14:5
+      //     ./in.cue:14:11
+      // E.b: non-concrete value >=5 in operand to -:
+      //     ./in.cue:13:5
+      //     ./in.cue:14:5
+      //     ./in.cue:14:11
     }
     b: (_|_){
-      // [cycle] cycle error:
-      //     ./in.cue:13:5
+      // [incomplete] E.b: non-concrete value >=5 in operand to -:
+      //     ./in.cue:13:5
+      //     ./in.cue:14:5
+      //     ./in.cue:14:11
     }
     c: (_|_){
-      // [cycle] cycle error:
-      //     ./in.cue:12:5
-      // cycle error:
-      //     ./in.cue:13:5
+      // [incomplete] E.b: non-concrete value >=5 in operand to -:
+      //     ./in.cue:13:5
+      //     ./in.cue:14:5
+      //     ./in.cue:14:11
     }
   }
   a: (int){ int }
-- out/compile --
--- in.cue
{
  s: string
  e1: (〈0;s〉 + 〈0;s〉)
  e2: (>"bar" & 〈0;s〉)
  e3: (>〈0;s〉 & "foo")
  e3b: >〈0;s〉
  e4: (>〈0;e1〉 & 〈0;s〉)
  e5: (<〈0;e5〉 & 〈0;s〉)
  E: {
    a: (〈0;c〉 - 〈0;b〉)
    b: (〈0;c〉 - 〈0;a〉)
    c: ((〈0;a〉 + 〈0;b〉) & >=5)
  }
  a: int
  okay: ((>10 & <〈0;a〉) + 3)
  issue1837: {
    p1: {
      context: {}
      x: 〈0;context〉.b
      if (〈0;x〉 == _|_(explicit error (_|_ literal) in source)) {
        message: "a"
      }
    }
    p2: {
      if (〈0;x〉 == _|_(explicit error (_|_ literal) in source)) {
        message: "a"
      }
      x: 〈0;context〉.b
      context: {}
    }
    p3: {
      if (〈0;x〉 == _|_(explicit error (_|_ literal) in source)) {
        message: "a"
      }
      context: {}
      x: 〈0;context〉.b
    }
  }
}
