-- in.cue --
root: {
	a: {
		$id: "list"
		out: [...int]
	}
	middle: {
		for x in a.out if x > 1 {
			"la\(x)": {
				$id: "sequenced"
				seq: x
				val: "foo\(x)"
			}
		}
	}
	// Run this after all generated tasks (so far)
	b: {
		$id: "list"
		$after: [for x in middle {x}]
		out: [...int]
	}
	after: {
		for x in b.out if x > 1 {
			"lb\(x)": {
				$id: "valToOut"
				val: "foo\(x)"
			}
		}
	}
}
-- out/run/errors --
-- out/run/t0 --
graph TD
  t0("root.a [Ready]")
  t1("root.b [Waiting]")
  t1-->t0

-- out/run/t1 --
graph TD
  t0("root.a [Terminated]")
  t1("root.b [Waiting]")
  t1-->t0
  t1-->t2
  t2("root.middle.la2 [Ready]")
  t2-->t0

-- out/run/t1/value --
{
	$id: "list"
	out: [1, 2]
}
-- out/run/t2 --
graph TD
  t0("root.a [Terminated]")
  t1("root.b [Ready]")
  t1-->t0
  t1-->t2
  t2("root.middle.la2 [Terminated]")
  t2-->t0

-- out/run/t2/value --
{
	$id: "sequenced"
	out: "foo2"
	seq: 2
	val: "foo2"
}
-- out/run/t3 --
graph TD
  t0("root.a [Terminated]")
  t1("root.b [Terminated]")
  t1-->t0
  t1-->t2
  t2("root.middle.la2 [Terminated]")
  t2-->t0
  t3("root.after.lb2 [Ready]")
  t3-->t1

-- out/run/t3/value --
{
	$id: "list"
	$after: [{
		$id: "sequenced"
		out: "foo2"
		seq: 2
		val: "foo2"
	}]
	out: [1, 2]
}
-- out/run/t4 --
graph TD
  t0("root.a [Terminated]")
  t1("root.b [Terminated]")
  t1-->t0
  t1-->t2
  t2("root.middle.la2 [Terminated]")
  t2-->t0
  t3("root.after.lb2 [Terminated]")
  t3-->t1

-- out/run/t4/value --
{
	$id: "valToOut"
	out: "foo2"
	val: "foo2"
}
-- out/run/t1/stats --
Leaks:  0
Freed:  21
Reused: 15
Allocs: 6
Retain: 0

Unifications: 21
Conjuncts:    35
Disjuncts:    21
-- out/run/t2/stats --
Leaks:  0
Freed:  23
Reused: 23
Allocs: 0
Retain: 0

Unifications: 23
Conjuncts:    44
Disjuncts:    23
-- out/run/t3/stats --
Leaks:  0
Freed:  28
Reused: 28
Allocs: 0
Retain: 0

Unifications: 28
Conjuncts:    57
Disjuncts:    28
-- out/run/t4/stats --
Leaks:  0
Freed:  29
Reused: 29
Allocs: 0
Retain: 0

Unifications: 29
Conjuncts:    63
Disjuncts:    29
-- out/run/stats/totals --
Leaks:  0
Freed:  101
Reused: 95
Allocs: 6
Retain: 0

Unifications: 101
Conjuncts:    199
Disjuncts:    101
