Skip to content

Commit

Permalink
internal/core/adt: fix issue 3599
Browse files Browse the repository at this point in the history
V3 has a special path for filtering disjuncts prematurely.
The code that investigated errors for
this path did not ignore errors within
lets or optional fields.

Fixes #3599

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I9c12a1810d8acc3e262e0b38fda52d580811d516
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1206942
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
  • Loading branch information
mpvl committed Jan 9, 2025
1 parent 9da90de commit 211b2a2
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 142 deletions.
205 changes: 64 additions & 141 deletions cue/testdata/disjunctions/errors.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,6 @@ Conjuncts: 268
Disjuncts: 206
-- out/evalalpha --
Errors:
issue3599.full.#Minio.container.action: 2 errors in empty disjunction:
issue3599.reduced.p1: 2 errors in empty disjunction:
issue3599.reduced.p1.a: conflicting values 2 and 1:
./issue3599.cue:32:9
./issue3599.cue:32:11
issue3599.reduced.p1.b: conflicting values 2 and 1:
./issue3599.cue:32:35
./issue3599.cue:32:37
issue516.x: 2 errors in empty disjunction:
issue516.x.match: field not allowed:
./in.cue:23:5
Expand All @@ -151,10 +143,6 @@ issue516.x.match.metrics.foo: field not allowed:
issue570.results.result: conflicting values "hello" and [...string] (mismatched types string and list):
./in.cue:3:19
./in.cue:12:12
explicit error (_|_ literal) in source:
./issue3599.cue:17:13
explicit error (_|_ literal) in source:
./issue3599.cue:20:13

Result:
(_|_){
Expand Down Expand Up @@ -275,10 +263,8 @@ Result:
c: (_){ _ }
}
}
issue3599: (_|_){
// [eval]
full: (_|_){
// [user]
issue3599: (struct){
full: (struct){
#Action: (#struct){
action: (#struct){ |((#struct){
read!: (string){ string }
Expand All @@ -294,16 +280,16 @@ Result:
}
}) }
}
#Minio: (_|_){
// [user]
container: (_|_){
// [user]
action: (_|_){
// [user] issue3599.full.#Minio.container.action: 2 errors in empty disjunction:
// explicit error (_|_ literal) in source:
// ./issue3599.cue:17:13
// explicit error (_|_ literal) in source:
// ./issue3599.cue:20:13
#Minio: (#struct){
container: (#struct){
action: (#struct){
write: (string){ "somefile.txt" }
read?: (_|_){
// [user] explicit error (_|_ literal) in source:
// ./issue3599.cue:9:12
// explicit error (_|_ literal) in source:
// ./issue3599.cue:20:13
}
}
}
doWrite: (bool){ |(*(bool){ true }, (bool){ bool }) }
Expand All @@ -312,17 +298,21 @@ Result:
}
}
}
reduced: (_|_){
// [eval]
p1: (_|_){
// [eval] issue3599.reduced.p1: 2 errors in empty disjunction:
// issue3599.reduced.p1.a: conflicting values 2 and 1:
// ./issue3599.cue:32:9
// ./issue3599.cue:32:11
// issue3599.reduced.p1.b: conflicting values 2 and 1:
// ./issue3599.cue:32:35
// ./issue3599.cue:32:37
}
reduced: (struct){
p1: (struct){ |((struct){
a?: (_|_){
// [eval] issue3599.reduced.p1.a: conflicting values 2 and 1:
// ./issue3599.cue:32:9
// ./issue3599.cue:32:11
}
}, (struct){
a: (string){ string }
b?: (_|_){
// [eval] issue3599.reduced.p1.b: conflicting values 2 and 1:
// ./issue3599.cue:32:35
// ./issue3599.cue:32:37
}
}) }
p2: (struct){ |((struct){
a?: (_|_){
// [eval] issue3599.reduced.p2.a: conflicting values 2 and 1:
Expand All @@ -338,24 +328,23 @@ Result:
}
}) }
}
let: (struct){
}
let: (struct){ |((struct){
}, (struct){
a: (int){ 1 }
let B#1 = (_|_){
// [eval] issue3599.let.B: conflicting values 2 and 1:
// ./issue3599.cue:40:29
// ./issue3599.cue:40:31
}
}) }
}
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -1,17 +1,24 @@
@@ -1,15 +1,10 @@
Errors:
+issue3599.full.#Minio.container.action: 2 errors in empty disjunction:
+issue3599.reduced.p1: 2 errors in empty disjunction:
+issue3599.reduced.p1.a: conflicting values 2 and 1:
+ ./issue3599.cue:32:9
+ ./issue3599.cue:32:11
+issue3599.reduced.p1.b: conflicting values 2 and 1:
+ ./issue3599.cue:32:35
+ ./issue3599.cue:32:37
issue516.x: 2 errors in empty disjunction:
issue516.x.match: field not allowed:
- ./in.cue:20:6
Expand All @@ -369,14 +358,8 @@ diff old new
- ./in.cue:2:11
./in.cue:3:19
./in.cue:12:12
+explicit error (_|_ literal) in source:
+ ./issue3599.cue:17:13
+explicit error (_|_ literal) in source:
+ ./issue3599.cue:20:13

Result:
(_|_){
@@ -19,17 +26,12 @@
@@ -19,17 +14,12 @@
issue570: (_|_){
// [eval]
results: (_|_){
Expand All @@ -395,7 +378,7 @@ diff old new
}
#Output: (#struct){ |((#struct){
result: (_){ _ }
@@ -59,18 +61,10 @@
@@ -59,18 +49,10 @@
x: (_|_){
// [eval] issue516.x: 2 errors in empty disjunction:
// issue516.x.match: field not allowed:
Expand All @@ -415,7 +398,7 @@ diff old new
metrics: (struct){
foo: (struct){
}
@@ -86,11 +80,11 @@
@@ -86,11 +68,11 @@
}
issue2916: (struct){
b: (struct){
Expand All @@ -429,7 +412,7 @@ diff old new
}
issue3576: (struct){
reduced: (struct){
@@ -136,19 +130,19 @@
@@ -136,13 +118,11 @@
reduced: (struct){
list: (_|_){
// [incomplete] issue3581.reduced.list: 2 errors in empty disjunction:
Expand All @@ -446,106 +429,46 @@ diff old new
}
c: (_){ _ }
}
}
- issue3599: (struct){
- full: (struct){
+ issue3599: (_|_){
+ // [eval]
+ full: (_|_){
+ // [user]
#Action: (#struct){
action: (#struct){ |((#struct){
read!: (string){ string }
@@ -164,16 +158,16 @@
}
}) }
}
- #Minio: (#struct){
- container: (#struct){
- action: (#struct){
- write: (string){ "somefile.txt" }
- read?: (_|_){
- // [user] explicit error (_|_ literal) in source:
- // ./issue3599.cue:9:12
- // explicit error (_|_ literal) in source:
- // ./issue3599.cue:20:13
- }
+ #Minio: (_|_){
+ // [user]
+ container: (_|_){
+ // [user]
+ action: (_|_){
+ // [user] issue3599.full.#Minio.container.action: 2 errors in empty disjunction:
+ // explicit error (_|_ literal) in source:
+ // ./issue3599.cue:17:13
+ // explicit error (_|_ literal) in source:
+ // ./issue3599.cue:20:13
}
}
doWrite: (bool){ |(*(bool){ true }, (bool){ bool }) }
@@ -182,27 +176,20 @@
}
}
}
- reduced: (struct){
- p1: (struct){ |((struct){
- a?: (_|_){
- // [eval] issue3599.reduced.p1.a: conflicting values 2 and 1:
@@ -186,7 +166,6 @@
p1: (struct){ |((struct){
a?: (_|_){
// [eval] issue3599.reduced.p1.a: conflicting values 2 and 1:
- // ./issue3599.cue:32:2
- // ./issue3599.cue:32:9
- // ./issue3599.cue:32:11
- }
- }, (struct){
- a: (string){ string }
- b?: (_|_){
- // [eval] issue3599.reduced.p1.b: conflicting values 2 and 1:
// ./issue3599.cue:32:9
// ./issue3599.cue:32:11
}
@@ -194,7 +173,6 @@
a: (string){ string }
b?: (_|_){
// [eval] issue3599.reduced.p1.b: conflicting values 2 and 1:
- // ./issue3599.cue:32:2
- // ./issue3599.cue:32:35
- // ./issue3599.cue:32:37
- }
- }) }
+ reduced: (_|_){
+ // [eval]
+ p1: (_|_){
+ // [eval] issue3599.reduced.p1: 2 errors in empty disjunction:
+ // issue3599.reduced.p1.a: conflicting values 2 and 1:
+ // ./issue3599.cue:32:9
+ // ./issue3599.cue:32:11
+ // issue3599.reduced.p1.b: conflicting values 2 and 1:
+ // ./issue3599.cue:32:35
+ // ./issue3599.cue:32:37
+ }
// ./issue3599.cue:32:35
// ./issue3599.cue:32:37
}
@@ -202,7 +180,6 @@
p2: (struct){ |((struct){
a?: (_|_){
// [eval] issue3599.reduced.p2.a: conflicting values 2 and 1:
- // ./issue3599.cue:37:2
// ./issue3599.cue:37:9
// ./issue3599.cue:37:11
}
@@ -210,21 +197,12 @@
@@ -210,7 +187,6 @@
a: (string){ string }
b?: (_|_){
// [eval] issue3599.reduced.p2.b: conflicting values 2 and 1:
- // ./issue3599.cue:37:2
// ./issue3599.cue:37:35
// ./issue3599.cue:37:37
}
}) }
}
- let: (struct){ |((struct){
- }, (struct){
- a: (int){ 1 }
- let B#1 = (_|_){
- // [eval] issue3599.let.B: conflicting values 2 and 1:
@@ -221,7 +197,6 @@
a: (int){ 1 }
let B#1 = (_|_){
// [eval] issue3599.let.B: conflicting values 2 and 1:
- // ./issue3599.cue:40:2
- // ./issue3599.cue:40:29
- // ./issue3599.cue:40:31
- }
- }) }
+ let: (struct){
+ }
}
}
// ./issue3599.cue:40:29
// ./issue3599.cue:40:31
}
-- diff/todo/p3 --
Missing error positions.
-- diff/explanation --
Expand Down
3 changes: 3 additions & 0 deletions internal/core/adt/disjunct2.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,9 @@ func (n *nodeContext) getErrorAll() *Bottom {
return err
}
for _, a := range n.node.Arcs {
if a.ArcType > ArcRequired || a.Label.IsLet() {
return nil
}
n := a.getState(n.ctx)
if n != nil {
if err := n.getErrorAll(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/core/adt/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var skipDebugDepErrors = map[string]int{
"cycle/evaluate": 1,
"cycle/structural": 14,
"disjunctions/edge": 1,
"disjunctions/errors": 3,
"disjunctions/errors": 2,
"disjunctions/elimination": 11,
"disjunctions/embed": 6,
"eval/conjuncts": 3,
Expand Down

0 comments on commit 211b2a2

Please sign in to comment.