#name: struct comprehension with template
#evalFull
-- in.cue --
result: [for _, v in service {v}]

service: [Name=string]: {
	name: *Name | string
	type: "service"
	port: *7080 | int
}
service: foo: {}
service: bar: {port: 8000}
service: baz: {name: "foobar"}
-- out/def --
result: [{
	name: *"foo" | string
	type: "service"
	port: *7080 | int
}, {
	name: *"bar" | string
	type: "service"
	port: 8000
}, {
	name: "foobar"
	type: "service"
	port: *7080 | int
}]
service: {
	{[Name=string]: {
		name: *Name | string, type: "service", port: *7080 | int
	}}
	foo: {
		name: *"foo" | string
		type: "service"
		port: *7080 | int
	}
	bar: {
		name: *"bar" | string
		type: "service"
		port: 8000
	}
	baz: {
		name: "foobar"
		type: "service"
		port: *7080 | int
	}
}
-- out/export --
result: [{
	name: "foo"
	type: "service"
	port: 7080
}, {
	name: "bar"
	type: "service"
	port: 8000
}, {
	name: "foobar"
	type: "service"
	port: 7080
}]
service: {
	foo: {
		name: "foo"
		type: "service"
		port: 7080
	}
	bar: {
		name: "bar"
		type: "service"
		port: 8000
	}
	baz: {
		name: "foobar"
		type: "service"
		port: 7080
	}
}
-- out/yaml --
result:
- name: foo
  type: service
  port: 7080
- name: bar
  type: service
  port: 8000
- name: foobar
  type: service
  port: 7080
service:
  foo:
    name: foo
    type: service
    port: 7080
  bar:
    name: bar
    type: service
    port: 8000
  baz:
    name: foobar
    type: service
    port: 7080
-- out/json --
{"result":[{"name":"foo","type":"service","port":7080},{"name":"bar","type":"service","port":8000},{"name":"foobar","type":"service","port":7080}],"service":{"foo":{"name":"foo","type":"service","port":7080},"bar":{"name":"bar","type":"service","port":8000},"baz":{"name":"foobar","type":"service","port":7080}}}
-- out/legacy-debug --
<0>{result: [<1>{name: "foo", type: "service", port: 7080},<2>{name: "bar", type: "service", port: 8000},<3>{name: "foobar", type: "service", port: 7080}], service: <4>{[]: <5>(Name: string)-><6>{name: (*<5>.Name | string), type: "service", port: (*7080 | int)}, foo: <7>{name: "foo", type: "service", port: 7080}, bar: <8>{name: "bar", type: "service", port: 8000}, baz: <9>{name: "foobar", type: "service", port: 7080}}}
-- out/compile --
--- in.cue
{
  result: [
    for _, v in 〈1;service〉 {
      〈1;v〉
    },
  ]
  service: {
    [string]: {
      name: (*〈1;-〉|string)
      type: "service"
      port: (*7080|int)
    }
  }
  service: {
    foo: {}
  }
  service: {
    bar: {
      port: 8000
    }
  }
  service: {
    baz: {
      name: "foobar"
    }
  }
}
-- out/eval/stats --
Leaks:  0
Freed:  51
Reused: 43
Allocs: 8
Retain: 4

Unifications: 27
Conjuncts:    70
Disjuncts:    55
-- out/eval --
(struct){
  result: (#list){
    0: (struct){
      name: (string){ |(*(string){ "foo" }, (string){ string }) }
      type: (string){ "service" }
      port: (int){ |(*(int){ 7080 }, (int){ int }) }
    }
    1: (struct){
      port: (int){ 8000 }
      name: (string){ |(*(string){ "bar" }, (string){ string }) }
      type: (string){ "service" }
    }
    2: (struct){
      name: (string){ "foobar" }
      type: (string){ "service" }
      port: (int){ |(*(int){ 7080 }, (int){ int }) }
    }
  }
  service: (struct){
    foo: (struct){
      name: (string){ |(*(string){ "foo" }, (string){ string }) }
      type: (string){ "service" }
      port: (int){ |(*(int){ 7080 }, (int){ int }) }
    }
    bar: (struct){
      port: (int){ 8000 }
      name: (string){ |(*(string){ "bar" }, (string){ string }) }
      type: (string){ "service" }
    }
    baz: (struct){
      name: (string){ "foobar" }
      type: (string){ "service" }
      port: (int){ |(*(int){ 7080 }, (int){ int }) }
    }
  }
}
