Skip to content

Commit

Permalink
internal/core/adt: add test for incomplete references in lets
Browse files Browse the repository at this point in the history
These errors should not be dropped.

Fixes #609

Change-Id: I83f02691df797f6f669272a9881626571e3cd37a
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/8209
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
mpvl committed Jan 15, 2021
1 parent 0ffde15 commit 5691606
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions cue/testdata/references/let.txtar
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-- in.cue --
import "list"

a1list: [{1}]
let A1 = a1list
Expand Down Expand Up @@ -36,6 +37,32 @@ a9list: [{9}]
let A9 = a9list
a9: b: c: { for x in A9 { v: 909 } }

// Issue #609:
// When a let value resolved to an incomplete value, it should pass this
// incomplete status to the expression in which it used. But 609 reported
// a gobbling of this incomplete status. The problem seemed to be not
// exclusive to the use of let, though.
incompleteLet: {
input: [1,2,3,4,5]

last: {
min: list.Min(input)
max: list.Max(input)
}

bar: {
let mn = last.min
let mx = list.max

min: mn
max: mx
}

x: {
if list.max < 0 {
}
}
}

-- out/compile --
--- in.cue
Expand Down Expand Up @@ -136,6 +163,26 @@ a9: b: c: { for x in A9 { v: 909 } }
}
}
}
incompleteLet: {
input: [
1,
2,
3,
4,
5,
]
last: {
min: 〈import;list〉.Min(〈1;input〉)
max: 〈import;list〉.Max(〈1;input〉)
}
bar: {
min: 〈0;let mn〉
max: 〈0;let mx〉
}
x: {
if (〈import;list〉.max < 0) {}
}
}
}
-- out/eval --
(struct){
Expand Down Expand Up @@ -211,4 +258,28 @@ a9: b: c: { for x in A9 { v: 909 } }
}
}
}
incompleteLet: (struct){
input: (#list){
0: (int){ 1 }
1: (int){ 2 }
2: (int){ 3 }
3: (int){ 4 }
4: (int){ 5 }
}
last: (struct){
min: (int){ 1 }
max: (int){ 5 }
}
bar: (struct){
min: (int){ 1 }
max: (_|_){
// [incomplete] incompleteLet.bar.max: undefined field max:
// ./in.cue:54:23
}
}
x: (_|_){
// [incomplete] incompleteLet.x: undefined field max:
// ./in.cue:61:17
}
}
}

0 comments on commit 5691606

Please sign in to comment.