#name: struct comprehensions
#evalPartial
-- in.cue --
obj: foo: a: "bar"
obj: [Name=string]: {
	a: *"dummy" | string
	if true {
		sub: as: a
	}
}

for k, v in {#def: 1, opt?: 2, _hid: 3, reg: 4} {
	"\(k)": v
}
-- out/def --
obj: {
	{[Name=string]: {
		a: *"dummy" | string, sub: {
			as: a
		}
	}}
	foo: {
		a: "bar"
		sub: {
			as: "bar"
		}
	}
}
reg: 4
-- out/export --
obj: {
	foo: {
		a: "bar"
		sub: {
			as: "bar"
		}
	}
}
reg: 4
-- out/yaml --
obj:
  foo:
    a: bar
    sub:
      as: bar
reg: 4
-- out/json --
{"obj":{"foo":{"a":"bar","sub":{"as":"bar"}}},"reg":4}
-- out/legacy-debug --
<0>{obj: <1>{[]: <2>(Name: string)-><3>{a: (*"dummy" | string) if true yield <4>{sub: <5>{as: <3>.a}}}, foo: <6>{a: "bar", sub: <7>{as: "bar"}}}, reg: 4}
-- out/compile --
--- in.cue
{
  obj: {
    foo: {
      a: "bar"
    }
  }
  obj: {
    [string]: {
      a: (*"dummy"|string)
      if true {
        sub: {
          as: 〈2;a〉
        }
      }
    }
  }
  for k, v in {
    #def: 1
    opt?: 2
    _hid: 3
    reg: 4
  } {
    "\(〈1;k〉)": 〈1;v〉
  }
}
-- out/eval/stats --
Leaks:  3
Freed:  11
Reused: 7
Allocs: 7
Retain: 2

Unifications: 10
Conjuncts:    19
Disjuncts:    13
-- out/eval --
(struct){
  obj: (struct){
    foo: (struct){
      a: (string){ "bar" }
      sub: (struct){
        as: (string){ "bar" }
      }
    }
  }
  reg: (int){ 4 }
}
