Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
internal/core/eval: verify issue 293 is fixed
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mpvl committed Sep 12, 2020
1 parent fbf9de3 commit ddd99d5
Showing 1 changed file with 59 additions and 1 deletion.
60 changes: 59 additions & 1 deletion cue/testdata/comprehensions/issue293.txtar
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -7,7 +25,33 @@ t: #C
}
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" }
}
Expand All @@ -18,6 +62,20 @@ t: p: "foo"
-- 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 {
Expand Down

0 comments on commit ddd99d5

Please sign in to comment.