Skip to content

Commit

Permalink
internal/core/adt: fix task completion across disjunction boundaries
Browse files Browse the repository at this point in the history
This change prevents resolver tasks from triggering
evaluating disjunctions of the same node.
This change fixes some issue with equality checking that
broke code in such scenarios.

To complete a task associated with a particular node,
one often must also complete the nodes it depends on.
This may cause a task, like a resolving task, to trigger
the running of a disjunction task. This, in turn, makes it
complicated to set up notification to have conjuncts put
in the right nodes.

But to avoid this complexity altogether, it ensures that
completeNodeTasks is not called during the running of a
task. Instead, it marks a node needing completion after a
task is completed.

Note that this change only addresses some of the cases that
were necessary to make things run. Further investigation is
needed to tighten up this construction.

Note that most test changes are difference in error line
reporting and reorderings. Other than that this fixes some tests.

Issue #2884

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: Idcdaab58ef27c29b47f822b668eb53e6c816980c
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1191586
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
  • Loading branch information
mpvl committed Apr 16, 2024
1 parent b944429 commit 8c6738a
Show file tree
Hide file tree
Showing 22 changed files with 335 additions and 380 deletions.
18 changes: 8 additions & 10 deletions cue/testdata/comprehensions/iferror.txtar
Expand Up @@ -161,9 +161,6 @@ Errors:
issue1972.err1: conflicting values [...{}] and {someCondition:_,patchs:[...{}],patchs,if someCondition {patchs:_}} (mismatched types list and struct):
./in.cue:61:8
./in.cue:63:11
issue1972.err1.patchs: field not allowed:
./in.cue:63:3
./in.cue:66:4
issue1972.err1.someCondition: field not allowed:
./in.cue:62:3
wrongConcreteType: cannot use 2 (type int) as type bool:
Expand Down Expand Up @@ -229,6 +226,8 @@ Result:
// [eval] issue1972.err1: conflicting values [...{}] and {someCondition:_,patchs:[...{}],patchs,if someCondition {patchs:_}} (mismatched types list and struct):
// ./in.cue:61:8
// ./in.cue:63:11
// issue1972.err1.someCondition: field not allowed:
// ./in.cue:62:3
#patchs: (#list){
}
#someCondition: (_){ _ }
Expand All @@ -248,22 +247,19 @@ Result:
diff old new
--- old
+++ new
@@ -1,7 +1,12 @@
@@ -1,7 +1,9 @@
Errors:
-issue1972.err1: conflicting values [] and {someCondition:_,patchs:[...{}],patchs,if someCondition {patchs:_}} (mismatched types list and struct):
- ./in.cue:54:12
+issue1972.err1: conflicting values [...{}] and {someCondition:_,patchs:[...{}],patchs,if someCondition {patchs:_}} (mismatched types list and struct):
./in.cue:61:8
+ ./in.cue:63:11
+issue1972.err1.patchs: field not allowed:
+ ./in.cue:63:3
+ ./in.cue:66:4
+issue1972.err1.someCondition: field not allowed:
+ ./in.cue:62:3
wrongConcreteType: cannot use 2 (type int) as type bool:
./in.cue:4:2
./in.cue:1:8
@@ -8,8 +13,6 @@
@@ -8,8 +10,6 @@
wrongType: cannot use int (type int) as type bool:
./in.cue:10:2
./in.cue:1:14
Expand All @@ -272,7 +268,7 @@ diff old new

Result:
(_|_){
@@ -31,8 +34,6 @@
@@ -31,8 +31,6 @@
incomplete: (_|_){
// [incomplete] incomplete: undefined field: d:
// ./in.cue:16:7
Expand All @@ -281,7 +277,7 @@ diff old new
list: (#list){
0: (int){ 1 }
1: (int){ 2 }
@@ -66,17 +67,21 @@
@@ -66,17 +64,23 @@
issue1972: (_|_){
// [eval]
err1: (_|_){
Expand All @@ -292,6 +288,8 @@ diff old new
- // issue1972.err1: invalid list index someCondition (type string):
- // ./in.cue:65:6
+ // ./in.cue:63:11
+ // issue1972.err1.someCondition: field not allowed:
+ // ./in.cue:62:3
#patchs: (#list){
}
- someCondition: (_){ _ }
Expand Down
73 changes: 38 additions & 35 deletions cue/testdata/comprehensions/pushdown.txtar
Expand Up @@ -753,13 +753,15 @@ Conjuncts: 636
Disjuncts: 464
-- out/evalalpha --
Errors:
noStackOverflowStructCycle.#list.tail: structural cycle
noStackOverflowStructCycle.list.tail: structural cycle
embed.fail1.p: field not allowed:
./in.cue:46:7
./in.cue:46:4
./in.cue:49:9
embed.fail4.p: field not allowed:
./in.cue:74:10
./in.cue:74:4
noStackOverflowStructCycle.#list.tail: structural cycle
noStackOverflowStructCycle.list.tail: structural cycle
fieldMismatch.a: cannot combine regular field "x" with 2:
./in.cue:139:7
./in.cue:137:3
Expand Down Expand Up @@ -811,10 +813,13 @@ Result:
// ./in.cue:30:3
}
}
embed: (struct){
fail1: (#struct){
embed: (_|_){
// [eval]
fail1: (_|_){
// [eval]
p: (_|_){
// [eval] embed.fail1.p: field not allowed:
// ./in.cue:46:7
// ./in.cue:46:4
// ./in.cue:49:9
}
Expand All @@ -831,9 +836,11 @@ Result:
}
#C3: (#struct){
}
fail4: (#struct){
fail4: (_|_){
// [eval]
p: (_|_){
// [eval] embed.fail4.p: field not allowed:
// ./in.cue:74:10
// ./in.cue:74:4
q: (int){ 1 }
}
Expand Down Expand Up @@ -1389,23 +1396,27 @@ Result:
diff old new
--- old
+++ new
@@ -1,27 +1,17 @@
@@ -1,27 +1,19 @@
Errors:
+noStackOverflowStructCycle.#list.tail: structural cycle
+noStackOverflowStructCycle.list.tail: structural cycle
embed.fail1.p: field not allowed:
- ./in.cue:37:9
- ./in.cue:38:7
- ./in.cue:45:3
- ./in.cue:45:12
+ ./in.cue:46:7
./in.cue:46:4
./in.cue:49:9
embed.fail4.p: field not allowed:
- ./in.cue:69:9
- ./in.cue:70:7
- ./in.cue:71:9
- ./in.cue:72:3
+ ./in.cue:74:10
./in.cue:74:4
noStackOverflowStructCycle.#list.tail: structural cycle
noStackOverflowStructCycle.list.tail: structural cycle
-noStackOverflowStructCycle.#list.tail: structural cycle
-noStackOverflowStructCycle.list.tail: structural cycle
-provideIncompleteSuccess.t2.a.c.d: field not allowed:
- ./in.cue:187:7
- ./in.cue:189:4
Expand All @@ -1420,58 +1431,50 @@ diff old new

Result:
(_|_){
@@ -63,20 +53,14 @@
@@ -63,8 +55,8 @@
}
fail: (struct){
a: (_|_){
- // [cycle] fail.a: cycle with field a.b:
- // ./in.cue:30:6
- }
- }
- embed: (_|_){
- // [eval]
- fail1: (_|_){
- // [eval]
+ // [incomplete] fail.a.b: cyclic reference to field b:
+ // ./in.cue:30:3
+ }
+ }
+ embed: (struct){
+ fail1: (#struct){
}
}
embed: (_|_){
@@ -73,10 +65,7 @@
// [eval]
p: (_|_){
// [eval] embed.fail1.p: field not allowed:
- // ./in.cue:37:9
- // ./in.cue:38:7
- // ./in.cue:45:3
- // ./in.cue:45:12
+ // ./in.cue:46:7
// ./in.cue:46:4
// ./in.cue:49:9
}
@@ -93,14 +77,9 @@
}
#C3: (#struct){
}
- fail4: (_|_){
- // [eval]
+ fail4: (#struct){
@@ -97,10 +86,7 @@
// [eval]
p: (_|_){
// [eval] embed.fail4.p: field not allowed:
- // ./in.cue:69:9
- // ./in.cue:70:7
- // ./in.cue:71:9
- // ./in.cue:72:3
+ // ./in.cue:74:10
// ./in.cue:74:4
q: (int){ 1 }
}
@@ -125,7 +104,6 @@
@@ -125,7 +111,6 @@
// [incomplete] embed.incomplete7.p: non-concrete value int in operand to +:
// ./in.cue:93:6
// ./in.cue:94:6
- // ./in.cue:95:3
}
q: (int){ int }
}
@@ -189,12 +167,12 @@
@@ -189,12 +174,12 @@
b: (bool){ bool }
}
x: (#struct){
Expand All @@ -1488,7 +1491,7 @@ diff old new
}
}
t2: (_|_){
@@ -211,10 +189,8 @@
@@ -211,10 +196,8 @@
// [eval]
d: (_|_){
// [eval] provideIncompleteSuccess.t2.a.c.d: field not allowed:
Expand All @@ -1500,7 +1503,7 @@ diff old new
}
}
b: (bool){ true }
@@ -245,17 +221,22 @@
@@ -245,17 +228,22 @@
}
cyclicError: (struct){
a: (_|_){
Expand All @@ -1527,7 +1530,7 @@ diff old new
}
}
midwayReferences: (struct){
@@ -412,17 +393,10 @@
@@ -412,17 +400,10 @@
}
}
E: (_|_){
Expand All @@ -1546,7 +1549,7 @@ diff old new
}
}
derefDisj2: (struct){
@@ -433,17 +407,10 @@
@@ -433,17 +414,10 @@
}
}
E: (_|_){
Expand All @@ -1565,7 +1568,7 @@ diff old new
}
}
bulk1: (struct){
@@ -562,13 +529,13 @@
@@ -562,13 +536,13 @@
}
envs: (struct){
e1: (#struct){
Expand All @@ -1583,7 +1586,7 @@ diff old new
}
}
}
@@ -590,7 +557,7 @@
@@ -590,7 +564,7 @@
y: (int){ 1 }
}
a: (struct){
Expand All @@ -1592,7 +1595,7 @@ diff old new
}
}
nestedWithEmbeddingOK: (struct){
@@ -605,9 +572,7 @@
@@ -605,9 +579,7 @@
_c: (struct){
y: (int){ 1 }
}
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/cycle/compbottom2.txtar
Expand Up @@ -790,6 +790,7 @@ self.isConcreteFail: t1: int value is not an error.
self.isNotConcrete: t1: int value is not an error.
-- diff/todo/p3 --
sameStruct.cycleFail: Harmonize and improve cycle errors
cycleFail.t1.p1.raises?.a: error needs to be reported at parent node.
-- out/eval --
(struct){
self: (struct){
Expand Down

0 comments on commit 8c6738a

Please sign in to comment.