-- in.cue --
list: [2, 3]
a: [3, for x in list {x}, for x in list {x}]
b: [3, if true {3}, for x in list if x > 2 {x}]

// issue574: Tests that if and for comprehensions inside list literals
// correctly include or exclude elements based on conditions.
// https://cuelang.org/issue/574
issue574: {
	greet: true
	bye:   true

	message1: [
		if greet {"hello"},
		"how are you doing?",
		"bye",
	]

	message2: [
		if !greet {"hello"},
		"how are you doing?",
		if bye {
			"bye"
		},
	]
}
-- out/compile --
--- in.cue
{
  list: [
    2,
    3,
  ]
  a: [
    3,
    for _, x in 〈1;list〉 {
      〈1;x〉
    },
    for _, x in 〈1;list〉 {
      〈1;x〉
    },
  ]
  b: [
    3,
    if true {
      3
    },
    for _, x in 〈1;list〉 if (〈0;x〉 > 2) {
      〈1;x〉
    },
  ]
  issue574: {
    greet: true
    bye: true
    message1: [
      if 〈1;greet〉 {
        "hello"
      },
      "how are you doing?",
      "bye",
    ]
    message2: [
      if !〈1;greet〉 {
        "hello"
      },
      "how are you doing?",
      if 〈1;bye〉 {
        "bye"
      },
    ]
  }
}
