Skip to content

Commit

Permalink
internal/core/adt: better error positions
Browse files Browse the repository at this point in the history
We can extract more error posistions by visiting
the entire conjunct tree.

This fixes many of the discrepancies between
V2 and V3, w.r.t. error positions.

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: I87a9629ab80dbb70d2d16d474ddc4d118019bf22
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202659
TryBot-Result: CUEcueckoo <[email protected]>
Reviewed-by: Matthew Sackman <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
  • Loading branch information
mpvl committed Oct 18, 2024
1 parent 2bce38d commit 6e0525b
Show file tree
Hide file tree
Showing 28 changed files with 349 additions and 1,276 deletions.
26 changes: 26 additions & 0 deletions cue/testdata/builtins/incomplete.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,18 @@ Result:
x: (_|_){
// [incomplete] incompleteListError.x: non-concrete value _ in operand to +:
// ./in.cue:72:11
// ./in.cue:73:11
}
y: (_){ _ }
decimal: (_|_){
// [incomplete] incompleteListError.x: non-concrete value _ in operand to +:
// ./in.cue:72:11
// ./in.cue:73:11
}
str: (_|_){
// [incomplete] incompleteListError.x: non-concrete value _ in operand to +:
// ./in.cue:72:11
// ./in.cue:73:11
}
}
badListType: (_|_){
Expand Down Expand Up @@ -320,6 +323,29 @@ diff old new
// ./in.cue:59:16
// ./in.cue:58:16
}
@@ -129,15 +129,18 @@
x: (_|_){
// [incomplete] incompleteListError.x: non-concrete value _ in operand to +:
// ./in.cue:72:11
+ // ./in.cue:73:11
}
y: (_){ _ }
decimal: (_|_){
// [incomplete] incompleteListError.x: non-concrete value _ in operand to +:
// ./in.cue:72:11
- }
- str: (_|_){
- // [incomplete] incompleteListError.x: non-concrete value _ in operand to +:
- // ./in.cue:72:11
+ // ./in.cue:73:11
+ }
+ str: (_|_){
+ // [incomplete] incompleteListError.x: non-concrete value _ in operand to +:
+ // ./in.cue:72:11
+ // ./in.cue:73:11
}
}
badListType: (_|_){
-- out/eval --
Errors:
badListType.decimal: cannot use 2 (type int) as list in argument 1 to list.Max:
Expand Down
133 changes: 0 additions & 133 deletions cue/testdata/builtins/matchif.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -20,65 +20,6 @@ Retain: 24
Unifications: 98
Conjuncts: 154
Disjuncts: 98
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -2,22 +2,18 @@
regularFields.err1: invalid value {x:10,y:6} (does not satisfy matchIf({x!:>2}, {y!:5}, {y!:1})): conflicting values 5 and 6:
./in.cue:2:7
./in.cue:2:30
- ./in.cue:7:8
./in.cue:7:19
regularFields.err2: invalid value {x:11,y:6} (does not satisfy matchIf({x!:>2}, {y!:5}, {y!:1})): conflicting values 5 and 6:
./in.cue:2:7
./in.cue:2:30
- ./in.cue:8:8
./in.cue:8:19
regularFields.err3: invalid value {x:2,y:5} (does not satisfy matchIf({x!:>2}, {y!:5}, {y!:1})): conflicting values 1 and 5:
./in.cue:2:7
./in.cue:2:39
- ./in.cue:9:8
./in.cue:9:18
regularFields.err4: invalid value {x:1,y:2} (does not satisfy matchIf({x!:>2}, {y!:5}, {y!:1})): conflicting values 1 and 2:
./in.cue:2:7
./in.cue:2:39
- ./in.cue:10:8
./in.cue:10:18

Result:
@@ -45,7 +41,6 @@
// [eval] regularFields.err1: invalid value {x:10,y:6} (does not satisfy matchIf({x!:>2}, {y!:5}, {y!:1})): conflicting values 5 and 6:
// ./in.cue:2:7
// ./in.cue:2:30
- // ./in.cue:7:8
// ./in.cue:7:19
x: (int){ 10 }
y: (int){ 6 }
@@ -54,7 +49,6 @@
// [eval] regularFields.err2: invalid value {x:11,y:6} (does not satisfy matchIf({x!:>2}, {y!:5}, {y!:1})): conflicting values 5 and 6:
// ./in.cue:2:7
// ./in.cue:2:30
- // ./in.cue:8:8
// ./in.cue:8:19
x: (int){ 11 }
y: (int){ 6 }
@@ -63,7 +57,6 @@
// [eval] regularFields.err3: invalid value {x:2,y:5} (does not satisfy matchIf({x!:>2}, {y!:5}, {y!:1})): conflicting values 1 and 5:
// ./in.cue:2:7
// ./in.cue:2:39
- // ./in.cue:9:8
// ./in.cue:9:18
x: (int){ 2 }
y: (int){ 5 }
@@ -72,7 +65,6 @@
// [eval] regularFields.err4: invalid value {x:1,y:2} (does not satisfy matchIf({x!:>2}, {y!:5}, {y!:1})): conflicting values 1 and 2:
// ./in.cue:2:7
// ./in.cue:2:39
- // ./in.cue:10:8
// ./in.cue:10:18
x: (int){ 1 }
y: (int){ 2 }
-- out/eval --
Errors:
regularFields.err1: invalid value {x:10,y:6} (does not satisfy matchIf({x!:>2}, {y!:5}, {y!:1})): conflicting values 5 and 6:
Expand Down Expand Up @@ -161,80 +102,6 @@ Result:
}
}
}
-- out/evalalpha --
Errors:
regularFields.err1: invalid value {x:10,y:6} (does not satisfy matchIf({x!:>2}, {y!:5}, {y!:1})): conflicting values 5 and 6:
./in.cue:2:7
./in.cue:2:30
./in.cue:7:19
regularFields.err2: invalid value {x:11,y:6} (does not satisfy matchIf({x!:>2}, {y!:5}, {y!:1})): conflicting values 5 and 6:
./in.cue:2:7
./in.cue:2:30
./in.cue:8:19
regularFields.err3: invalid value {x:2,y:5} (does not satisfy matchIf({x!:>2}, {y!:5}, {y!:1})): conflicting values 1 and 5:
./in.cue:2:7
./in.cue:2:39
./in.cue:9:18
regularFields.err4: invalid value {x:1,y:2} (does not satisfy matchIf({x!:>2}, {y!:5}, {y!:1})): conflicting values 1 and 2:
./in.cue:2:7
./in.cue:2:39
./in.cue:10:18

Result:
(_|_){
// [eval]
regularFields: (_|_){
// [eval]
ok1: (struct){
x: (int){ 10 }
y: (int){ 5 }
}
ok2: (struct){
x: (int){ 11 }
y: (int){ 5 }
}
ok3: (struct){
x: (int){ 2 }
y: (int){ 1 }
}
ok4: (struct){
x: (int){ 1 }
y: (int){ 1 }
}
err1: (_|_){
// [eval] regularFields.err1: invalid value {x:10,y:6} (does not satisfy matchIf({x!:>2}, {y!:5}, {y!:1})): conflicting values 5 and 6:
// ./in.cue:2:7
// ./in.cue:2:30
// ./in.cue:7:19
x: (int){ 10 }
y: (int){ 6 }
}
err2: (_|_){
// [eval] regularFields.err2: invalid value {x:11,y:6} (does not satisfy matchIf({x!:>2}, {y!:5}, {y!:1})): conflicting values 5 and 6:
// ./in.cue:2:7
// ./in.cue:2:30
// ./in.cue:8:19
x: (int){ 11 }
y: (int){ 6 }
}
err3: (_|_){
// [eval] regularFields.err3: invalid value {x:2,y:5} (does not satisfy matchIf({x!:>2}, {y!:5}, {y!:1})): conflicting values 1 and 5:
// ./in.cue:2:7
// ./in.cue:2:39
// ./in.cue:9:18
x: (int){ 2 }
y: (int){ 5 }
}
err4: (_|_){
// [eval] regularFields.err4: invalid value {x:1,y:2} (does not satisfy matchIf({x!:>2}, {y!:5}, {y!:1})): conflicting values 1 and 2:
// ./in.cue:2:7
// ./in.cue:2:39
// ./in.cue:10:18
x: (int){ 1 }
y: (int){ 2 }
}
}
}
-- out/compile --
--- in.cue
{
Expand Down
Loading

0 comments on commit 6e0525b

Please sign in to comment.