Skip to content

Commit

Permalink
internal/core/adt: detect closed lists as fatal errors
Browse files Browse the repository at this point in the history
Tightening of error handling. This may eliminate some
disjunctions earlier, causing better error handling.

Issue #2244

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I0b059969b2b272c903ed4e4eea368822da93d822
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/549658
Unity-Result: CUEcueckoo <cueckoo@cuelang.org>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
  • Loading branch information
mpvl committed Mar 14, 2023
1 parent 9b1f222 commit 06fbefe
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
12 changes: 6 additions & 6 deletions cue/testdata/references/index.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ varNegativeIndex: {
a: [1, 2, 3][n]
}
-- out/eval/stats --
Leaks: 15
Leaks: 12
Freed: 36
Reused: 33
Allocs: 18
Retain: 15
Allocs: 15
Retain: 12

Unifications: 43
Conjuncts: 56
Disjuncts: 48
Unifications: 40
Conjuncts: 50
Disjuncts: 45
-- out/eval --
Errors:
outOfBoundsDisjunction: invalid list index 1 (out of bounds):
Expand Down
12 changes: 6 additions & 6 deletions cue/testdata/resolve/016_index.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ e7: def["b"]
e7: 〈0;def〉["b"]
}
-- out/eval/stats --
Leaks: 16
Leaks: 10
Freed: 32
Reused: 26
Allocs: 22
Retain: 23
Allocs: 16
Retain: 16

Unifications: 40
Conjuncts: 61
Disjuncts: 53
Unifications: 34
Conjuncts: 48
Disjuncts: 46
-- out/eval --
Errors:
c: invalid list index "3" (type string):
Expand Down
3 changes: 3 additions & 0 deletions internal/core/adt/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,9 @@ func (c *OpContext) lookup(x *Vertex, pos token.Pos, l Feature, state VertexStat
// inability to look up a field as "final", as it may resolve down the
// line.
permanent := x.status > Conjuncts
if m, _ := x.BaseValue.(*ListMarker); m != nil && !m.IsOpen {
permanent = true
}
if (state > Partial || permanent) && !x.Accept(c, l) {
code = 0
} else if hasCycle {
Expand Down

0 comments on commit 06fbefe

Please sign in to comment.