Skip to content

Commit e231c49

Browse files
committed
internal/core/adt: update environment for disjunctions
When passing tasks crossing disjunctions, we need to update the corresponding Environments to reflect the updated Vertex values. This was not done for disjunctions. This meant that a disjunction within a field that gets unified with another disjunction might not resolve correctly. This is fixed by simply updating the respective Environment. The disjunction array was already copied before, so this should not give significant performance issues. Fixes #3891 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I1dce73ae8f7491f446fe3a66d33388e578b6bf6c Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1214809 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Daniel Martí <[email protected]>
1 parent bb2204f commit e231c49

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

cue/testdata/eval/disjunctions.txtar

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ Result:
746746
}
747747
issue3891: (struct){
748748
reduced: (struct){
749-
x: (_){ _ }
749+
x: (_){ |(*(int){ 1 }, (_){ _ }) }
750750
a: ~(issue3891.reduced.b)
751751
b: (struct){
752752
y: (int){ 1 }
@@ -759,7 +759,7 @@ Result:
759759
sub2: (string){ "bar" }
760760
}
761761
}
762-
foo: (_){ _ }
762+
foo: (_){ |(*(string){ "bar" }, (_){ _ }) }
763763
}
764764
_transform: (struct){
765765
in: (_){ _ }
@@ -903,28 +903,17 @@ diff old new
903903
x: (bool){ true }
904904
}) }
905905
bar: (#struct){ |((#struct){
906-
@@ -436,10 +415,8 @@
907-
}
906+
@@ -437,9 +416,7 @@
908907
issue3891: (struct){
909908
reduced: (struct){
910-
- x: (_){ |(*(int){ 1 }, (_){ _ }) }
909+
x: (_){ |(*(int){ 1 }, (_){ _ }) }
911910
- a: (struct){
912911
- y: (int){ 1 }
913912
- }
914-
+ x: (_){ _ }
915913
+ a: ~(issue3891.reduced.b)
916914
b: (struct){
917915
y: (int){ 1 }
918916
}
919-
@@ -451,7 +428,7 @@
920-
sub2: (string){ "bar" }
921-
}
922-
}
923-
- foo: (_){ |(*(string){ "bar" }, (_){ _ }) }
924-
+ foo: (_){ _ }
925-
}
926-
_transform: (struct){
927-
in: (_){ _ }
928917
@@ -475,14 +452,14 @@
929918
}
930919
full: (struct){

internal/core/adt/overlay.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,10 @@ func (ctx *overlayContext) cloneNodeContext(n *nodeContext) *nodeContext {
309309
if len(n.disjunctions) > 0 {
310310
// Do not clone cc in disjunctions, as it is identified by underlying.
311311
// We only need to clone the cc in disjunctCCs.
312-
d.disjunctions = append(d.disjunctions, n.disjunctions...)
312+
for _, x := range n.disjunctions {
313+
x.env = ctx.derefDisjunctsEnv(x.env)
314+
d.disjunctions = append(d.disjunctions, x)
315+
}
313316
}
314317

315318
return d

0 commit comments

Comments
 (0)