Skip to content

Commit 5ce7ba4

Browse files
committedJan 16, 2025·
internal/core/adt: propagate completion signal if disjunction is resolved
When a Vertex completes, it signals dependent tasks that they can now resume. Although this also happens for individual disjuncts, this signal is not propagated at the level of the field in which the disjunct is defined. This should be the case if the disjunct is disambiguated or if there is an ambiguated default. Fixes #3681 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: Icfb1fdc2b33b9e91ab347298a2685a490b32fccf Reviewed-on: https://gerrithub.io/c/cue-lang/cue/+/1207320 TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Matthew Sackman <[email protected]>
1 parent 682462a commit 5ce7ba4

File tree

3 files changed

+52
-35
lines changed

3 files changed

+52
-35
lines changed
 

‎cue/testdata/cycle/chain.txtar

+33-16
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,19 @@ Disjuncts: 8919
460460
}
461461
full: (struct){
462462
#RecurseN: (_|_){
463-
// [cycle] cycle error
463+
// [incomplete] issue2052.full.#RecurseN: error in call to list.Range: non-concrete value _:
464+
// ./issue2052.cue:111:15
465+
#maxiter: (int){ |(*(int){ 4 }, (int){ &(>=0, int) }) }
466+
#funcFactory: (#struct){
467+
#next: (_){ _ }
468+
#func: (_){ _ }
469+
}
470+
#funcs: (_|_){
471+
// [incomplete] issue2052.full.#RecurseN: error in call to list.Range: non-concrete value _:
472+
// ./issue2052.cue:111:15
473+
// issue2052.full.#RecurseN.#funcs: invalid interpolation: non-concrete value _ (type _):
474+
// ./issue2052.cue:117:11
475+
}
464476
}
465477
#DepthF: (#struct){
466478
#next: (_){ _ }
@@ -1145,30 +1157,35 @@ diff old new
11451157
#basic: ((null|string)){ |((string){ string }, (null){ null }) }
11461158
out: (int){ 1 }
11471159
}
1148-
@@ -223,20 +215,8 @@
1160+
@@ -223,19 +215,19 @@
11491161
}
11501162
}
11511163
full: (struct){
11521164
- #RecurseN: (_){
11531165
- _
1154-
- #maxiter: (int){ |(*(int){ 4 }, (int){ &(>=0, int) }) }
1155-
- #funcFactory: (#struct){
1156-
- #next: (_){ _ }
1157-
- #func: (_){ _ }
1158-
- }
1166+
+ #RecurseN: (_|_){
1167+
+ // [incomplete] issue2052.full.#RecurseN: error in call to list.Range: non-concrete value _:
1168+
+ // ./issue2052.cue:111:15
1169+
#maxiter: (int){ |(*(int){ 4 }, (int){ &(>=0, int) }) }
1170+
#funcFactory: (#struct){
1171+
#next: (_){ _ }
1172+
#func: (_){ _ }
1173+
}
11591174
- #funcs: (#struct){
11601175
- "4": (null){ null }
11611176
- "0": (_){ _ }
11621177
- "1": (_){ _ }
11631178
- "2": (_){ _ }
11641179
- "3": (_){ _ }
1165-
- }
1166-
+ #RecurseN: (_|_){
1167-
+ // [cycle] cycle error
1180+
+ #funcs: (_|_){
1181+
+ // [incomplete] issue2052.full.#RecurseN: error in call to list.Range: non-concrete value _:
1182+
+ // ./issue2052.cue:111:15
1183+
+ // issue2052.full.#RecurseN.#funcs: invalid interpolation: non-concrete value _ (type _):
1184+
+ // ./issue2052.cue:117:11
1185+
}
11681186
}
11691187
#DepthF: (#struct){
1170-
#next: (_){ _ }
1171-
@@ -245,7 +225,13 @@
1188+
@@ -245,7 +237,13 @@
11721189
#basic: ((null|string|bytes|number)){ |((int){ int }, (number){ number }, (string){ string }, (bytes){ bytes }, (null){ null }) }
11731190
out: (int){
11741191
1
@@ -1183,7 +1200,7 @@ diff old new
11831200
}
11841201
}
11851202
}
1186-
@@ -258,98 +244,170 @@
1203+
@@ -258,98 +256,170 @@
11871204
#basic: ((null|string|bytes|number)){ |((int){ int }, (number){ number }, (string){ string }, (bytes){ bytes }, (null){ null }) }
11881205
out: (int){
11891206
1
@@ -1446,7 +1463,7 @@ diff old new
14461463
}
14471464
}
14481465
}
1449-
@@ -357,7 +415,13 @@
1466+
@@ -357,7 +427,13 @@
14501467
#basic: ((null|string|bytes|number)){ |((int){ int }, (number){ number }, (string){ string }, (bytes){ bytes }, (null){ null }) }
14511468
out: (int){
14521469
1
@@ -1461,7 +1478,7 @@ diff old new
14611478
}
14621479
}
14631480
tree: (struct){
1464-
@@ -371,49 +435,7 @@
1481+
@@ -371,49 +447,7 @@
14651482
}
14661483
cow: (string){ "moo" }
14671484
}
@@ -1512,7 +1529,7 @@ diff old new
15121529
#in: (#struct){
15131530
a: (#struct){
15141531
foo: (string){ "bar" }
1515-
@@ -425,6 +447,192 @@
1532+
@@ -425,6 +459,192 @@
15161533
}
15171534
cow: (string){ "moo" }
15181535
}

‎cue/testdata/eval/disjunctions.txtar

+4-19
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,7 @@ Result:
317317
issue3681: (struct){
318318
out: (struct){
319319
one: (string){ |(*(string){ "fallback" }, (string){ string }) }
320-
two: (_|_){
321-
// [incomplete] issue3681.out.two: invalid interpolation: non-concrete value _ (type _):
322-
// ./dependencies.cue:26:12
323-
}
320+
two: (string){ "fallback" }
324321
}
325322
strDefault: (string){ |(*(string){ "fallback" }, (string){ string }) }
326323
#strDefaultDef: (string){ |(*(string){ "fallback" }, (string){ string }) }
@@ -647,19 +644,7 @@ diff old new
647644
}
648645
#S: ((string|struct)){ |((string){ string }, (#struct){
649646
}) }
650-
@@ -80,7 +69,10 @@
651-
issue3681: (struct){
652-
out: (struct){
653-
one: (string){ |(*(string){ "fallback" }, (string){ string }) }
654-
- two: (string){ "fallback" }
655-
+ two: (_|_){
656-
+ // [incomplete] issue3681.out.two: invalid interpolation: non-concrete value _ (type _):
657-
+ // ./dependencies.cue:26:12
658-
+ }
659-
}
660-
strDefault: (string){ |(*(string){ "fallback" }, (string){ string }) }
661-
#strDefaultDef: (string){ |(*(string){ "fallback" }, (string){ string }) }
662-
@@ -110,19 +102,12 @@
647+
@@ -110,19 +99,12 @@
663648
// [eval] f: 2 errors in empty disjunction:
664649
// f.name: conflicting values "int" and "str":
665650
// ./in.cue:5:8
@@ -680,7 +665,7 @@ diff old new
680665
}
681666
e1: (struct){
682667
a: ((null|struct)){ |((null){ null }, (struct){
683-
@@ -234,8 +219,8 @@
668+
@@ -234,8 +216,8 @@
684669
e: (struct){
685670
foobar: (#struct){
686671
b: (#struct){
@@ -690,7 +675,7 @@ diff old new
690675
}
691676
}
692677
}
693-
@@ -337,6 +322,9 @@
678+
@@ -337,6 +319,9 @@
694679
let Ok#1 = (bool){ true }
695680
}, (#struct){
696681
_ok: (bool){ true }

‎internal/core/adt/disjunct2.go

+15
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,21 @@ func (n *nodeContext) processDisjunctions() *Bottom {
351351
n.disjuncts = append(n.disjuncts, cross...)
352352
}
353353

354+
var completed condition
355+
numDefaults := 0
356+
if len(n.disjuncts) == 1 {
357+
completed = n.disjuncts[0].completed
358+
}
359+
for _, d := range n.disjuncts {
360+
if d.defaultMode == isDefault {
361+
numDefaults++
362+
completed = d.completed
363+
}
364+
}
365+
if numDefaults == 1 || len(n.disjuncts) == 1 {
366+
n.signal(completed)
367+
}
368+
354369
return nil
355370
}
356371

0 commit comments

Comments
 (0)
Please sign in to comment.