#IgnoreConcrete: true
#InferTasks: true
-- in.cue --
import (
	"strings"
	"tool/cli"
)

#Input: INPUT={
	kind: string
	outKey: string | *"default"
	if kind != "foo" {
		outKey: INPUT.kind
	}
}
inputs: f: #Input & { kind: "foo" }
inputs: b: #Input & { kind: "bar" }

outputs: [string]: string
for _, input in inputs {
	outputs: "\(input.outKey)": input.kind
}

root: print: cli.Print & {
	text: strings.Join([for key, val in outputs { "key=\(key) val=\(val)" }], "\n")
}
-- out/run/errors --
-- out/run/t0 --
graph TD
  t0("root.print [Ready]")

-- out/run/t1 --
graph TD
  t0("root.print [Terminated]")

-- out/run/t1/value --
{
	$id:    "tool/cli.Print"
	stdout: "foo"
	text: """
		key=default val=foo
		key=bar val=bar
		"""
}
-- out/run-v3/t1/stats --
Leaks:  1
Freed:  30
Reused: 17
Allocs: 14
Retain: 0

Unifications: 23
Conjuncts:    60
Disjuncts:    8
ResolveDep:   20

NumCloseIDs: 17
-- diff/-out/run-v3/t1/stats<==>+out/run/t1/stats --
diff old new
--- old
+++ new
@@ -1,13 +1,12 @@
-Leaks:  0
-Freed:  33
-Reused: 26
-Allocs: 7
-Retain: 1
+Leaks:  1
+Freed:  30
+Reused: 17
+Allocs: 14
+Retain: 0
 
 Unifications: 23
-Conjuncts:    61
-Disjuncts:    34
-
-MisalignedConjunct: 7
-
-NumCloseIDs: 4
+Conjuncts:    60
+Disjuncts:    8
+ResolveDep:   20
+
+NumCloseIDs: 17
-- out/run/t1/stats --
Leaks:  0
Freed:  33
Reused: 26
Allocs: 7
Retain: 1

Unifications: 23
Conjuncts:    61
Disjuncts:    34

MisalignedConjunct: 7

NumCloseIDs: 4
-- out/run-v3/stats/totals --
Leaks:  1
Freed:  30
Reused: 17
Allocs: 14
Retain: 0

Unifications: 23
Conjuncts:    60
Disjuncts:    8
ResolveDep:   20

NumCloseIDs: 17
-- diff/-out/run-v3/stats/totals<==>+out/run/stats/totals --
diff old new
--- old
+++ new
@@ -1,13 +1,12 @@
-Leaks:  0
-Freed:  33
-Reused: 26
-Allocs: 7
-Retain: 1
+Leaks:  1
+Freed:  30
+Reused: 17
+Allocs: 14
+Retain: 0
 
 Unifications: 23
-Conjuncts:    61
-Disjuncts:    34
-
-MisalignedConjunct: 7
-
-NumCloseIDs: 4
+Conjuncts:    60
+Disjuncts:    8
+ResolveDep:   20
+
+NumCloseIDs: 17
-- out/run/stats/totals --
Leaks:  0
Freed:  33
Reused: 26
Allocs: 7
Retain: 1

Unifications: 23
Conjuncts:    61
Disjuncts:    34

MisalignedConjunct: 7

NumCloseIDs: 4
