Skip to content

Commit

Permalink
internal/core/adt: fix disjunction error issue
Browse files Browse the repository at this point in the history
V3 used CombineErrors to combine errors from
the various disjuncts into a single Bottom value.
CombineErrors takes the code of the worst error.
However, for disjunctions we actually want the
code of the least worst error.

This change makes V3 use the same error creation
logic as V2, using some wrapper code. As a result,
V3 now also produces the "empty disjunction"
messages which were previously missing.

Note that now we have the "empty disjunction"
messages, we can see that the reported count
of failed disjunctions is somewhat off in some
tests. diff/todos are added where appropriate.

Issue #3600
Fixes #3581

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: I0ca92c190976d51fffddac6010e11a88505e876b
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1206284
Reviewed-by: Daniel Martí <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
  • Loading branch information
mpvl committed Dec 23, 2024
1 parent 8288686 commit c21e546
Show file tree
Hide file tree
Showing 15 changed files with 288 additions and 719 deletions.
31 changes: 16 additions & 15 deletions cue/testdata/comprehensions/pushdown.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,8 @@ Result:
}
}
E: (_|_){
// [incomplete] voidEliminationSuccess.derefDisj1.E.f: operand e of '!' not concrete (was bool):
// [incomplete] voidEliminationSuccess.derefDisj1.E: 2 errors in empty disjunction:
// voidEliminationSuccess.derefDisj1.E.f: operand e of '!' not concrete (was bool):
// ./in.cue:417:7
// voidEliminationSuccess.derefDisj1.E.h: operand g of '!' not concrete (was bool):
// ./in.cue:420:7
Expand All @@ -1222,7 +1223,8 @@ Result:
}
}
E: (_|_){
// [incomplete] voidEliminationSuccess.derefDisj2.E.f: operand e of '!' not concrete (was bool):
// [incomplete] voidEliminationSuccess.derefDisj2.E: 2 errors in empty disjunction:
// voidEliminationSuccess.derefDisj2.E.f: operand e of '!' not concrete (was bool):
// ./in.cue:435:7
// voidEliminationSuccess.derefDisj2.E.h: operand g of '!' not concrete (was bool):
// ./in.cue:438:7
Expand Down Expand Up @@ -1742,14 +1744,14 @@ diff old new
#F: (#struct){
e: (bool){ bool }
f: (_|_){
@@ -418,17 +370,10 @@
@@ -418,17 +370,11 @@
}
}
E: (_|_){
- // [incomplete] voidEliminationSuccess.derefDisj1.E: 2 errors in empty disjunction::
- // ./in.cue:407:28
- // voidEliminationSuccess.derefDisj1.E.f: operand e of '!' not concrete (was bool):
+ // [incomplete] voidEliminationSuccess.derefDisj1.E.f: operand e of '!' not concrete (was bool):
+ // [incomplete] voidEliminationSuccess.derefDisj1.E: 2 errors in empty disjunction:
// voidEliminationSuccess.derefDisj1.E.f: operand e of '!' not concrete (was bool):
// ./in.cue:417:7
// voidEliminationSuccess.derefDisj1.E.h: operand g of '!' not concrete (was bool):
// ./in.cue:420:7
Expand All @@ -1761,14 +1763,14 @@ diff old new
}
}
derefDisj2: (struct){
@@ -439,17 +384,10 @@
@@ -439,17 +385,11 @@
}
}
E: (_|_){
- // [incomplete] voidEliminationSuccess.derefDisj2.E: 2 errors in empty disjunction::
- // ./in.cue:425:28
- // voidEliminationSuccess.derefDisj2.E.f: operand e of '!' not concrete (was bool):
+ // [incomplete] voidEliminationSuccess.derefDisj2.E.f: operand e of '!' not concrete (was bool):
+ // [incomplete] voidEliminationSuccess.derefDisj2.E: 2 errors in empty disjunction:
// voidEliminationSuccess.derefDisj2.E.f: operand e of '!' not concrete (was bool):
// ./in.cue:435:7
// voidEliminationSuccess.derefDisj2.E.h: operand g of '!' not concrete (was bool):
// ./in.cue:438:7
Expand All @@ -1780,7 +1782,7 @@ diff old new
}
}
bulk1: (struct){
@@ -572,9 +510,7 @@
@@ -572,9 +512,7 @@
// [eval]
e: (_|_){
// [eval] structShare.err1.x.d.e: field not allowed:
Expand All @@ -1791,7 +1793,7 @@ diff old new
// ./in.cue:591:9
}
}
@@ -598,13 +534,13 @@
@@ -598,13 +536,13 @@
}
envs: (struct){
e1: (#struct){
Expand All @@ -1809,7 +1811,7 @@ diff old new
}
}
}
@@ -641,9 +577,8 @@
@@ -641,9 +579,8 @@
_c: (struct){
y: (int){ 1 }
}
Expand All @@ -1821,7 +1823,7 @@ diff old new
}
}
errorPropagation: (_|_){
@@ -701,10 +636,10 @@
@@ -701,10 +638,10 @@
}
foo: (#struct){
kind: (string){ "foo" }
Expand All @@ -1834,7 +1836,7 @@ diff old new
}
}
regular: (_|_){
@@ -717,16 +652,12 @@
@@ -717,16 +654,12 @@
foo: (_|_){
// [eval]
kind: (string){ "foo" }
Expand All @@ -1854,7 +1856,7 @@ diff old new
}
}
}
@@ -738,10 +669,10 @@
@@ -738,10 +671,10 @@
}
foo: (#struct){
kind: (string){ "foo" }
Expand Down Expand Up @@ -1900,7 +1902,6 @@ Unifications: 444
Conjuncts: 721
Disjuncts: 516
-- diff/todo/p2 --
Missing empty disjunction message.
provideIncompleteSuccess.t2.a.c.d: missing error: probably correct.
A bit esoteric, but should probably work.
-- diff/explanation --
Expand Down
188 changes: 8 additions & 180 deletions cue/testdata/cycle/disjunction.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -142,58 +142,15 @@ Result:
-- out/evalalpha --
Errors:
cycle.a: structural cycle
issue3042.data: 3 errors in empty disjunction:
issue3042.data: conflicting values [...#nesting] and {secret:{infra:[{name:"bar1"}]}} (mismatched types list and struct):
./issue3042.cue:5:57
./issue3042.cue:7:19
issue3042.data: conflicting values string and {secret:{infra:[{name:"bar1"}]}} (mismatched types string and struct):
./issue3042.cue:5:12
./issue3042.cue:7:19
issue3042.data.secret: conflicting values [...#nesting] and {infra:[{name:"bar1"}]} (mismatched types list and struct):
./issue3042.cue:5:57
./issue3042.cue:8:11
issue3042.data.secret: conflicting values string and {infra:[{name:"bar1"}]} (mismatched types string and struct):
./issue3042.cue:5:12
./issue3042.cue:8:11
issue3042.data.secret: field not allowed:
./issue3042.cue:8:3
issue3042.data.secret.infra: conflicting values [{name:"bar1"}] and string (mismatched types list and string):
./issue3042.cue:5:12
./issue3042.cue:9:11
issue3042.data.secret.infra: conflicting values [{name:"bar1"}] and {name?:#foo,[string]:#nesting} (mismatched types list and struct):
./issue3042.cue:5:21
./issue3042.cue:9:11
issue3042.data.secret.infra: field not allowed:
./issue3042.cue:9:4
issue3042.data.secret.infra.0: conflicting values [...#nesting] and {name:"bar1"} (mismatched types list and struct):
./issue3042.cue:5:57
./issue3042.cue:10:5
issue3042.data.secret.infra.0: conflicting values string and {name:"bar1"} (mismatched types string and struct):
./issue3042.cue:5:12
./issue3042.cue:10:5
issue3042.data.secret.infra.0: field not allowed:
./issue3042.cue:10:5
issue3042.data.secret.infra.0.name: conflicting values "bar1" and [...#nesting] (mismatched types string and list):
./issue3042.cue:5:57
./issue3042.cue:10:12
issue3042.data.secret.infra.0.name: conflicting values "bar1" and {name?:#foo,[string]:#nesting} (mismatched types string and struct):
./issue3042.cue:5:21
./issue3042.cue:10:12
issue3042.data.secret.infra.0.name: field not allowed:
./issue3042.cue:10:6
issue3042.data.secret.infra.0.name: invalid value "bar1" (out of bound =~"^foo"):
./issue3042.cue:4:8
./issue3042.cue:5:29
./issue3042.cue:5:45
./issue3042.cue:10:12
issue3042.data.secret: field not allowed:
./issue3042.cue:5:57
./issue3042.cue:8:3
issue3042.data.secret.infra: field not allowed:
./issue3042.cue:5:57
./issue3042.cue:9:4
issue3042.data.secret.infra.0.name: field not allowed:
./issue3042.cue:5:57
./issue3042.cue:10:6

Result:
(_|_){
Expand Down Expand Up @@ -262,58 +219,15 @@ Result:
}, (list){
}) }
data: (_|_){
// [eval] issue3042.data: conflicting values [...#nesting] and {secret:{infra:[{name:"bar1"}]}} (mismatched types list and struct):
// [eval] issue3042.data: 3 errors in empty disjunction:
// issue3042.data: conflicting values [...#nesting] and {secret:{infra:[{name:"bar1"}]}} (mismatched types list and struct):
// ./issue3042.cue:5:57
// ./issue3042.cue:7:19
// issue3042.data: conflicting values string and {secret:{infra:[{name:"bar1"}]}} (mismatched types string and struct):
// ./issue3042.cue:5:12
// ./issue3042.cue:7:19
// issue3042.data.secret: conflicting values [...#nesting] and {infra:[{name:"bar1"}]} (mismatched types list and struct):
// ./issue3042.cue:5:57
// ./issue3042.cue:8:11
// issue3042.data.secret: conflicting values string and {infra:[{name:"bar1"}]} (mismatched types string and struct):
// ./issue3042.cue:5:12
// ./issue3042.cue:8:11
// issue3042.data.secret: field not allowed:
// ./issue3042.cue:8:3
// issue3042.data.secret.infra: conflicting values [{name:"bar1"}] and string (mismatched types list and string):
// ./issue3042.cue:5:12
// ./issue3042.cue:9:11
// issue3042.data.secret.infra: conflicting values [{name:"bar1"}] and {name?:#foo,[string]:#nesting} (mismatched types list and struct):
// ./issue3042.cue:5:21
// ./issue3042.cue:9:11
// issue3042.data.secret.infra: field not allowed:
// ./issue3042.cue:9:4
// issue3042.data.secret.infra.0: conflicting values [...#nesting] and {name:"bar1"} (mismatched types list and struct):
// ./issue3042.cue:5:57
// ./issue3042.cue:10:5
// issue3042.data.secret.infra.0: conflicting values string and {name:"bar1"} (mismatched types string and struct):
// ./issue3042.cue:5:12
// ./issue3042.cue:10:5
// issue3042.data.secret.infra.0: field not allowed:
// ./issue3042.cue:10:5
// issue3042.data.secret.infra.0.name: conflicting values "bar1" and [...#nesting] (mismatched types string and list):
// ./issue3042.cue:5:57
// ./issue3042.cue:10:12
// issue3042.data.secret.infra.0.name: conflicting values "bar1" and {name?:#foo,[string]:#nesting} (mismatched types string and struct):
// ./issue3042.cue:5:21
// ./issue3042.cue:10:12
// issue3042.data.secret.infra.0.name: field not allowed:
// ./issue3042.cue:10:6
// issue3042.data.secret.infra.0.name: invalid value "bar1" (out of bound =~"^foo"):
// ./issue3042.cue:4:8
// ./issue3042.cue:5:29
// ./issue3042.cue:5:45
// ./issue3042.cue:10:12
// issue3042.data.secret: field not allowed:
// ./issue3042.cue:5:57
// ./issue3042.cue:8:3
// issue3042.data.secret.infra: field not allowed:
// ./issue3042.cue:5:57
// ./issue3042.cue:9:4
// issue3042.data.secret.infra.0.name: field not allowed:
// ./issue3042.cue:5:57
// ./issue3042.cue:10:6
secret: (struct){
infra: (_){ _ }
}
Expand All @@ -324,61 +238,18 @@ Result:
diff old new
--- old
+++ new
@@ -1,9 +1,61 @@
@@ -1,9 +1,18 @@
Errors:
cycle.a: structural cycle
+issue3042.data: 3 errors in empty disjunction:
+issue3042.data: conflicting values [...#nesting] and {secret:{infra:[{name:"bar1"}]}} (mismatched types list and struct):
+ ./issue3042.cue:5:57
+ ./issue3042.cue:7:19
+issue3042.data: conflicting values string and {secret:{infra:[{name:"bar1"}]}} (mismatched types string and struct):
+ ./issue3042.cue:5:12
+ ./issue3042.cue:7:19
+issue3042.data.secret: conflicting values [...#nesting] and {infra:[{name:"bar1"}]} (mismatched types list and struct):
+ ./issue3042.cue:5:57
+ ./issue3042.cue:8:11
+issue3042.data.secret: conflicting values string and {infra:[{name:"bar1"}]} (mismatched types string and struct):
+ ./issue3042.cue:5:12
+ ./issue3042.cue:8:11
+issue3042.data.secret: field not allowed:
+ ./issue3042.cue:8:3
+issue3042.data.secret.infra: conflicting values [{name:"bar1"}] and string (mismatched types list and string):
+ ./issue3042.cue:5:12
+ ./issue3042.cue:9:11
+issue3042.data.secret.infra: conflicting values [{name:"bar1"}] and {name?:#foo,[string]:#nesting} (mismatched types list and struct):
+ ./issue3042.cue:5:21
+ ./issue3042.cue:9:11
+issue3042.data.secret.infra: field not allowed:
+ ./issue3042.cue:9:4
+issue3042.data.secret.infra.0: conflicting values [...#nesting] and {name:"bar1"} (mismatched types list and struct):
+ ./issue3042.cue:5:57
+ ./issue3042.cue:10:5
+issue3042.data.secret.infra.0: conflicting values string and {name:"bar1"} (mismatched types string and struct):
+ ./issue3042.cue:5:12
+ ./issue3042.cue:10:5
+issue3042.data.secret.infra.0: field not allowed:
+ ./issue3042.cue:10:5
+issue3042.data.secret.infra.0.name: conflicting values "bar1" and [...#nesting] (mismatched types string and list):
+ ./issue3042.cue:5:57
+ ./issue3042.cue:10:12
+issue3042.data.secret.infra.0.name: conflicting values "bar1" and {name?:#foo,[string]:#nesting} (mismatched types string and struct):
+ ./issue3042.cue:5:21
+ ./issue3042.cue:10:12
+issue3042.data.secret.infra.0.name: field not allowed:
+ ./issue3042.cue:10:6
+issue3042.data.secret.infra.0.name: invalid value "bar1" (out of bound =~"^foo"):
+ ./issue3042.cue:4:8
+ ./issue3042.cue:5:29
+ ./issue3042.cue:5:45
+ ./issue3042.cue:10:12
+issue3042.data.secret: field not allowed:
+ ./issue3042.cue:5:57
+ ./issue3042.cue:8:3
+issue3042.data.secret.infra: field not allowed:
+ ./issue3042.cue:5:57
+ ./issue3042.cue:9:4
+issue3042.data.secret.infra.0.name: field not allowed:
+ ./issue3042.cue:5:57
+ ./issue3042.cue:10:6

Result:
(_|_){
Expand All @@ -387,7 +258,7 @@ diff old new
cycle: (_|_){
// [structural cycle]
a: (_|_){
@@ -58,22 +110,71 @@
@@ -58,22 +67,28 @@
x: (#list){
}
}
Expand All @@ -411,58 +282,15 @@ diff old new
- }
- name?: (string){ =~"^foo" }
+ data: (_|_){
+ // [eval] issue3042.data: conflicting values [...#nesting] and {secret:{infra:[{name:"bar1"}]}} (mismatched types list and struct):
+ // [eval] issue3042.data: 3 errors in empty disjunction:
+ // issue3042.data: conflicting values [...#nesting] and {secret:{infra:[{name:"bar1"}]}} (mismatched types list and struct):
+ // ./issue3042.cue:5:57
+ // ./issue3042.cue:7:19
+ // issue3042.data: conflicting values string and {secret:{infra:[{name:"bar1"}]}} (mismatched types string and struct):
+ // ./issue3042.cue:5:12
+ // ./issue3042.cue:7:19
+ // issue3042.data.secret: conflicting values [...#nesting] and {infra:[{name:"bar1"}]} (mismatched types list and struct):
+ // ./issue3042.cue:5:57
+ // ./issue3042.cue:8:11
+ // issue3042.data.secret: conflicting values string and {infra:[{name:"bar1"}]} (mismatched types string and struct):
+ // ./issue3042.cue:5:12
+ // ./issue3042.cue:8:11
+ // issue3042.data.secret: field not allowed:
+ // ./issue3042.cue:8:3
+ // issue3042.data.secret.infra: conflicting values [{name:"bar1"}] and string (mismatched types list and string):
+ // ./issue3042.cue:5:12
+ // ./issue3042.cue:9:11
+ // issue3042.data.secret.infra: conflicting values [{name:"bar1"}] and {name?:#foo,[string]:#nesting} (mismatched types list and struct):
+ // ./issue3042.cue:5:21
+ // ./issue3042.cue:9:11
+ // issue3042.data.secret.infra: field not allowed:
+ // ./issue3042.cue:9:4
+ // issue3042.data.secret.infra.0: conflicting values [...#nesting] and {name:"bar1"} (mismatched types list and struct):
+ // ./issue3042.cue:5:57
+ // ./issue3042.cue:10:5
+ // issue3042.data.secret.infra.0: conflicting values string and {name:"bar1"} (mismatched types string and struct):
+ // ./issue3042.cue:5:12
+ // ./issue3042.cue:10:5
+ // issue3042.data.secret.infra.0: field not allowed:
+ // ./issue3042.cue:10:5
+ // issue3042.data.secret.infra.0.name: conflicting values "bar1" and [...#nesting] (mismatched types string and list):
+ // ./issue3042.cue:5:57
+ // ./issue3042.cue:10:12
+ // issue3042.data.secret.infra.0.name: conflicting values "bar1" and {name?:#foo,[string]:#nesting} (mismatched types string and struct):
+ // ./issue3042.cue:5:21
+ // ./issue3042.cue:10:12
+ // issue3042.data.secret.infra.0.name: field not allowed:
+ // ./issue3042.cue:10:6
+ // issue3042.data.secret.infra.0.name: invalid value "bar1" (out of bound =~"^foo"):
+ // ./issue3042.cue:4:8
+ // ./issue3042.cue:5:29
+ // ./issue3042.cue:5:45
+ // ./issue3042.cue:10:12
+ // issue3042.data.secret: field not allowed:
+ // ./issue3042.cue:5:57
+ // ./issue3042.cue:8:3
+ // issue3042.data.secret.infra: field not allowed:
+ // ./issue3042.cue:5:57
+ // ./issue3042.cue:9:4
+ // issue3042.data.secret.infra.0.name: field not allowed:
+ // ./issue3042.cue:5:57
+ // ./issue3042.cue:10:6
+ secret: (struct){
+ infra: (_){ _ }
}
Expand Down
Loading

0 comments on commit c21e546

Please sign in to comment.