From 06fbefe5f6c864294e945b8f7190ab643852f4aa Mon Sep 17 00:00:00 2001 From: Marcel van Lohuizen Date: Thu, 9 Feb 2023 20:16:27 +0100 Subject: [PATCH] internal/core/adt: detect closed lists as fatal errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tightening of error handling. This may eliminate some disjunctions earlier, causing better error handling. Issue #2244 Signed-off-by: Marcel van Lohuizen Change-Id: I0b059969b2b272c903ed4e4eea368822da93d822 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/549658 Unity-Result: CUEcueckoo TryBot-Result: CUEcueckoo Reviewed-by: Daniel Martí --- cue/testdata/references/index.txtar | 12 ++++++------ cue/testdata/resolve/016_index.txtar | 12 ++++++------ internal/core/adt/context.go | 3 +++ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/cue/testdata/references/index.txtar b/cue/testdata/references/index.txtar index 81fb2a48b29..cf958da77b0 100644 --- a/cue/testdata/references/index.txtar +++ b/cue/testdata/references/index.txtar @@ -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): diff --git a/cue/testdata/resolve/016_index.txtar b/cue/testdata/resolve/016_index.txtar index be564bcd2ff..bec1271c944 100644 --- a/cue/testdata/resolve/016_index.txtar +++ b/cue/testdata/resolve/016_index.txtar @@ -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): diff --git a/internal/core/adt/context.go b/internal/core/adt/context.go index b8aefafbdd7..b15d56c096e 100644 --- a/internal/core/adt/context.go +++ b/internal/core/adt/context.go @@ -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 {