internal/core/eval: verify issue 342 is fixed
Fixes #342
Change-Id: I7d85c5e1e721b99c3059995525ff8469f8457ff0
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6946
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cue/testdata/definitions/issue342.txtar b/cue/testdata/definitions/issue342.txtar
new file mode 100644
index 0000000..bfbc353
--- /dev/null
+++ b/cue/testdata/definitions/issue342.txtar
@@ -0,0 +1,79 @@
+-- in.cue --
+X: {
+ #Simple: {
+ ref: string
+ }
+
+ #Complex: {
+ {
+ ref: string
+ } | {
+ local: string
+ }
+ }
+
+ var: "XXX"
+
+ // Validate(concrete) after Fill() on Complex.ref from a "static" key will succeed
+ "test_1": #Complex
+
+ // Validate(concrete) after Fill() on "#Simple.ref" from a "dynamic" key will succeed
+ "test_2_\(var)": #Simple
+
+ // Validate(concrete) after Fill() on Complex.ref from a "dynamic" key will fail
+ "test_3_\(var)": #Complex
+
+ test_3_XXX: ref: "FOO"
+}
+
+Z: X.test_3_XXX.ref
+-- out/eval --
+(struct){
+ X: (struct){
+ #Simple: (#struct){
+ ref: (string){ string }
+ }
+ #Complex: (struct){ |((#struct){
+ ref: (string){ string }
+ }, (#struct){
+ local: (string){ string }
+ }) }
+ var: (string){ "XXX" }
+ test_1: (struct){ |((#struct){
+ ref: (string){ string }
+ }, (#struct){
+ local: (string){ string }
+ }) }
+ test_3_XXX: (#struct){
+ ref: (string){ "FOO" }
+ }
+ test_2_XXX: (#struct){
+ ref: (string){ string }
+ }
+ }
+ Z: (string){ "FOO" }
+}
+-- out/compile --
+--- in.cue
+{
+ X: {
+ #Simple: {
+ ref: string
+ }
+ #Complex: {
+ ({
+ ref: string
+ }|{
+ local: string
+ })
+ }
+ var: "XXX"
+ test_1: 〈0;#Complex〉
+ "test_2_\(〈0;var〉)": 〈0;#Simple〉
+ "test_3_\(〈0;var〉)": 〈0;#Complex〉
+ test_3_XXX: {
+ ref: "FOO"
+ }
+ }
+ Z: 〈0;X〉.test_3_XXX.ref
+}