-- in.cue --
b: {for k, v in a {"\(k)": v + 1}}
a: {b: 1, c: 2}

x: {for k, v in y {"\(k)": v}}
y: {} // check that empty struct after reference works.

k: {for v in e {v}}
e: int

comprehensionBinds: {
	a: {for _ in [1] {a: _}}
	b: {for _, _ in [1] {a: _}}
}
-- out/eval/stats --
Leaks:  2
Freed:  16
Reused: 12
Allocs: 6
Retain: 7

Unifications: 18
Conjuncts:    18
Disjuncts:    21
-- out/eval --
Errors:
k: cannot range over e (found int, want list or struct):
    ./in.cue:7:14

Result:
(_|_){
  // [eval]
  b: (struct){
    b: (int){ 2 }
    c: (int){ 3 }
  }
  a: (struct){
    b: (int){ 1 }
    c: (int){ 2 }
  }
  x: (struct){
  }
  y: (struct){
  }
  k: (_|_){
    // [eval] k: cannot range over e (found int, want list or struct):
    //     ./in.cue:7:14
  }
  e: (int){ int }
  comprehensionBinds: (struct){
    a: (struct){
      a: (_){ _ }
    }
    b: (struct){
      a: (_){ _ }
    }
  }
}
-- out/compile --
--- in.cue
{
  b: {
    for k, v in 〈1;a〉 {
      "\(〈1;k〉)": (〈1;v〉 + 1)
    }
  }
  a: {
    b: 1
    c: 2
  }
  x: {
    for k, v in 〈1;y〉 {
      "\(〈1;k〉)": 〈1;v〉
    }
  }
  y: {}
  k: {
    for _, v in 〈1;e〉 {
      〈1;v〉
    }
  }
  e: int
  comprehensionBinds: {
    a: {
      for _, _ in [
        1,
      ] {
        a: _
      }
    }
    b: {
      for _, _ in [
        1,
      ] {
        a: _
      }
    }
  }
}
