-- in.cue --
circularIf: {
	#list: {
		tail: #list | *null
		if tail != null {
		}
	}
}

circularFor: {
	#list: {
		tail: #list | *null
		for x in tail != null {
		}
	}
}

// Print a bit more sensible error message than "empty disjunction" here.
// Issue #465
userError: {
	a: string | *_|_
	if a != "" {
	}
}

intField: {
	for i, _ in [1, 2] {
		(i): {
		}
	}
}

// Issue #2403
conflictRangingOverSelf: {
	x: {
		name: string
		age:  int
	}

	x: {
		for k, _ in x {
			(k): k
		}
	}
}
-- out/eval/stats --
Leaks:  1
Freed:  28
Reused: 22
Allocs: 7
Retain: 1

Unifications: 19
Conjuncts:    40
Disjuncts:    29
-- out/evalalpha --
Errors:
conflictRangingOverSelf.x.age: conflicting values int and "age" (mismatched types int and string):
    ./in.cue:36:9
    ./in.cue:40:3
circularFor.#list: cannot range over tail != null (found bool, want list or struct):
    ./in.cue:12:12
intField: integer fields not supported:
    ./in.cue:27:4

Result:
(_|_){
  // [eval]
  circularIf: (struct){
    #list: (#struct){
      tail: (null){ null }
    }
  }
  circularFor: (_|_){
    // [eval]
    #list: (_|_){
      // [eval] circularFor.#list: cannot range over tail != null (found bool, want list or struct):
      //     ./in.cue:12:12
      tail: (null){ null }
    }
  }
  userError: (_|_){
    // [incomplete] userError: non-concrete value string in operand to !=:
    //     ./in.cue:21:5
    //     ./in.cue:20:5
    a: (string){ string }
  }
  intField: (_|_){
    // [eval] intField: integer fields not supported:
    //     ./in.cue:27:4
  }
  conflictRangingOverSelf: (_|_){
    // [eval]
    x: (_|_){
      // [eval]
      name: (string){ "name" }
      age: (_|_){
        // [eval] conflictRangingOverSelf.x.age: conflicting values int and "age" (mismatched types int and string):
        //     ./in.cue:36:9
        //     ./in.cue:40:3
      }
    }
  }
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -2,7 +2,6 @@
 conflictRangingOverSelf.x.age: conflicting values int and "age" (mismatched types int and string):
     ./in.cue:36:9
     ./in.cue:40:3
-    ./in.cue:41:9
 circularFor.#list: cannot range over tail != null (found bool, want list or struct):
     ./in.cue:12:12
 intField: integer fields not supported:
@@ -13,9 +12,7 @@
   // [eval]
   circularIf: (struct){
     #list: (#struct){
-      tail: ((null|struct)){ |(*(null){ null }, (#struct){
-          tail: (null){ null }
-        }) }
+      tail: (null){ null }
     }
   }
   circularFor: (_|_){
@@ -35,10 +32,6 @@
   intField: (_|_){
     // [eval] intField: integer fields not supported:
     //     ./in.cue:27:4
-    0: (struct){
-    }
-    1: (struct){
-    }
   }
   conflictRangingOverSelf: (_|_){
     // [eval]
@@ -49,7 +42,6 @@
         // [eval] conflictRangingOverSelf.x.age: conflicting values int and "age" (mismatched types int and string):
         //     ./in.cue:36:9
         //     ./in.cue:40:3
-        //     ./in.cue:41:9
       }
     }
   }
-- diff/todo/p2 --
Missing error message.
-- out/eval --
Errors:
conflictRangingOverSelf.x.age: conflicting values int and "age" (mismatched types int and string):
    ./in.cue:36:9
    ./in.cue:40:3
    ./in.cue:41:9
circularFor.#list: cannot range over tail != null (found bool, want list or struct):
    ./in.cue:12:12
intField: integer fields not supported:
    ./in.cue:27:4

Result:
(_|_){
  // [eval]
  circularIf: (struct){
    #list: (#struct){
      tail: ((null|struct)){ |(*(null){ null }, (#struct){
          tail: (null){ null }
        }) }
    }
  }
  circularFor: (_|_){
    // [eval]
    #list: (_|_){
      // [eval] circularFor.#list: cannot range over tail != null (found bool, want list or struct):
      //     ./in.cue:12:12
      tail: (null){ null }
    }
  }
  userError: (_|_){
    // [incomplete] userError: non-concrete value string in operand to !=:
    //     ./in.cue:21:5
    //     ./in.cue:20:5
    a: (string){ string }
  }
  intField: (_|_){
    // [eval] intField: integer fields not supported:
    //     ./in.cue:27:4
    0: (struct){
    }
    1: (struct){
    }
  }
  conflictRangingOverSelf: (_|_){
    // [eval]
    x: (_|_){
      // [eval]
      name: (string){ "name" }
      age: (_|_){
        // [eval] conflictRangingOverSelf.x.age: conflicting values int and "age" (mismatched types int and string):
        //     ./in.cue:36:9
        //     ./in.cue:40:3
        //     ./in.cue:41:9
      }
    }
  }
}
-- out/compile --
--- in.cue
{
  circularIf: {
    #list: {
      tail: (〈1;#list〉|*null)
      if (〈0;tail〉 != null) {}
    }
  }
  circularFor: {
    #list: {
      tail: (〈1;#list〉|*null)
      for _, x in (〈0;tail〉 != null) {}
    }
  }
  userError: {
    a: (string|*_|_(explicit error (_|_ literal) in source))
    if (〈0;a〉 != "") {}
  }
  intField: {
    for i, _ in [
      1,
      2,
    ] {
      〈1;i〉: {}
    }
  }
  conflictRangingOverSelf: {
    x: {
      name: string
      age: int
    }
    x: {
      for k, _ in 〈1;x〉 {
        〈1;k〉: 〈1;k〉
      }
    }
  }
}
