internal/core/eval: verify issue 293 is fixed
Fixes #293
Change-Id: I48168c62acc68ce03877eed756fee70a3777f754
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/7045
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cue/testdata/comprehensions/issue293.txtar b/cue/testdata/comprehensions/issue293.txtar
index d2b69ed..3bd38ef 100644
--- a/cue/testdata/comprehensions/issue293.txtar
+++ b/cue/testdata/comprehensions/issue293.txtar
@@ -1,4 +1,22 @@
+
-- in.cue --
+#T: {
+ if true {
+ // We'd like to restrict the possible members of x in this case,
+ // but this doesn't work.
+ x: close({
+ f1: int
+ })
+ }
+ x: _
+}
+z: #T & {
+ x: {
+ f1: 99
+ f2: "i want to disallow this"
+ }
+}
+
t: #C
#C: {
if true {
@@ -7,7 +25,33 @@
}
t: p: "foo"
-- out/eval --
-(struct){
+Errors:
+z.x: field `f2` not allowed:
+ ./in.cue:5:12
+ ./in.cue:11:4
+ ./in.cue:14:3
+
+Result:
+(_|_){
+ // [eval]
+ #T: (#struct){
+ x: (#struct){
+ f1: (int){ int }
+ }
+ }
+ z: (_|_){
+ // [eval]
+ x: (_|_){
+ // [eval]
+ f1: (int){ 99 }
+ f2: (_|_){
+ // [eval] z.x: field `f2` not allowed:
+ // ./in.cue:5:12
+ // ./in.cue:11:4
+ // ./in.cue:14:3
+ }
+ }
+ }
t: (#struct){
p: (string){ "foo" }
}
@@ -18,6 +62,20 @@
-- out/compile --
--- in.cue
{
+ #T: {
+ if true {
+ x: close({
+ f1: int
+ })
+ }
+ x: _
+ }
+ z: (〈0;#T〉 & {
+ x: {
+ f1: 99
+ f2: "i want to disallow this"
+ }
+ })
t: 〈0;#C〉
#C: {
if true {