Skip to content

Commit

Permalink
internal/core/adt: don't cache incomplete errors for let
Browse files Browse the repository at this point in the history
These may be resolved later.

Issue #1116

Signed-off-by: Marcel van Lohuizen <[email protected]>

Change-Id: I46b8dda41193b41f5b6b0fd341164a2568697bfc
Signed-off-by: Marcel van Lohuizen <[email protected]>
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/528052
Reviewed-by: Marcel van Lohuizen <[email protected]>
  • Loading branch information
mpvl committed Nov 25, 2021
1 parent 4f3988f commit 9982526
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
44 changes: 44 additions & 0 deletions cue/testdata/references/let.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ incompleteLet: {
}
}
}
issue1116: {
a: {
#a: ["a", "b"]
let List = #a
List[len(List)-1]
}
b: {
let List = #a
List[len(List)-1]
#a: ["a", "b"]
}
}

-- out/compile --
--- in.cue
Expand Down Expand Up @@ -183,6 +195,22 @@ incompleteLet: {
if (〈import;list〉.max < 0) {}
}
}
issue1116: {
a: {
#a: [
"a",
"b",
]
〈0;let List〉[(len(〈0;let List〉) - 1)]
}
b: {
〈0;let List〉[(len(〈0;let List〉) - 1)]
#a: [
"a",
"b",
]
}
}
}
-- out/eval --
(struct){
Expand Down Expand Up @@ -282,4 +310,20 @@ incompleteLet: {
// ./in.cue:61:17
}
}
issue1116: (struct){
a: (string){
"b"
#a: (#list){
0: (string){ "a" }
1: (string){ "b" }
}
}
b: (string){
"b"
#a: (#list){
0: (string){ "a" }
1: (string){ "b" }
}
}
}
}
4 changes: 3 additions & 1 deletion internal/core/adt/composite.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ func (e *Environment) evalCached(c *OpContext, x Expr) Value {
c.e, c.src = e, x.Source()
v = c.evalState(x, Partial) // TODO: should this be Finalized?
c.e, c.src = env, src
e.cache[x] = v
if b, ok := v.(*Bottom); !ok || !b.IsIncomplete() {
e.cache[x] = v
}
}
return v
}
Expand Down

0 comments on commit 9982526

Please sign in to comment.