# Tests that a comprehension-generated struct merged into a list element
# constrained by a closed definition correctly rejects fields not declared
# in the definition. Fields introduced via comprehension inside a list
# literal should still be subject to closedness checks.
# Issue: https://cuelang.org/issue/153
-- in.cue --
Foo: {
	listOfCloseds: [...#Closed]
}

#Closed: {
	a: int | *0
}

Junk: {
	b: 2
}

Foo & {
	listOfCloseds: [{
		for k, v in Junk {
			"\(k)": v
		}
	}]
}
-- out/compile --
--- in.cue
{
  Foo: {
    listOfCloseds: [
      ...〈2;#Closed〉,
    ]
  }
  #Closed: {
    a: (int|*0)
  }
  Junk: {
    b: 2
  }
  (〈0;Foo〉 & {
    listOfCloseds: [
      {
        for k, v in 〈3;Junk〉 {
          "\(〈1;k〉)": 〈1;v〉
        }
      },
    ]
  })
}
