Skip to content

Commit

Permalink
internal/core/adt: merge Conjunct and Partial processing
Browse files Browse the repository at this point in the history
There were some cases where conjuncts could be added after
the Conjuncts state had been reached. This is okay, as there
is a separate mechanism to verify such additions are legal.
But not adding those can lead to lost information.

Tests for this were added before and will be fixed after
removing a workaround that worked around the issue fixed
here, but introduced errors itself.

Issue #2113
Fixes #2131

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: I74522731007393b96c6ba69acc688ca044067f3f
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/546598
Reviewed-by: Roger Peppe <[email protected]>
Unity-Result: CUEcueckoo <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
  • Loading branch information
mpvl committed Nov 24, 2022
1 parent 129c343 commit 121894c
Show file tree
Hide file tree
Showing 115 changed files with 131 additions and 144 deletions.
2 changes: 1 addition & 1 deletion cue/testdata/basicrewrite/018_self-reference_cycles.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Retain: 7

Unifications: 6
Conjuncts: 22
Disjuncts: 6
Disjuncts: 7
-- out/eval --
(struct){
a: (_|_){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Retain: 4

Unifications: 18
Conjuncts: 37
Disjuncts: 18
Disjuncts: 21
-- out/eval --
(struct){
a: (int){ 100 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Retain: 3

Unifications: 6
Conjuncts: 8
Disjuncts: 6
Disjuncts: 8
-- out/eval --
(struct){
x: (int){ 200 }
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/basicrewrite/aliases/aliases.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Retain: 2

Unifications: 9
Conjuncts: 15
Disjuncts: 9
Disjuncts: 10
-- out/eval --
(struct){
t0: (struct){
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/benchmarks/cycle.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Retain: 1

Unifications: 15
Conjuncts: 30
Disjuncts: 25
Disjuncts: 26
-- out/eval --
(struct){
sameValues: (struct){
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/benchmarks/listdedup.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Retain: 1

Unifications: 18724
Conjuncts: 100730
Disjuncts: 24096
Disjuncts: 24097
-- out/eval --
(struct){
A: (#struct){ |((#struct){
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/builtins/056_issue314.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Retain: 17

Unifications: 45
Conjuncts: 77
Disjuncts: 45
Disjuncts: 62
-- out/eval --
(struct){
x: (#struct){
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/builtins/closed.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Retain: 27

Unifications: 178
Conjuncts: 354
Disjuncts: 188
Disjuncts: 189
-- out/eval --
Errors:
b.x: field not allowed:
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/builtins/incomplete.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Retain: 32

Unifications: 109
Conjuncts: 265
Disjuncts: 129
Disjuncts: 147
-- out/eval --
Errors:
badListType.decimal: cannot use 2 (type int) as list in argument 1 to list.Max:
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/builtins/list/sort.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Retain: 2

Unifications: 20
Conjuncts: 33
Disjuncts: 20
Disjuncts: 22
-- out/eval --
(struct){
a: (#list){
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/compile/scope.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Retain: 7

Unifications: 52
Conjuncts: 107
Disjuncts: 52
Disjuncts: 55
-- out/eval --
Errors:
schema.next: structural cycle
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/comprehensions/015_list_comprehension.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Retain: 5

Unifications: 19
Conjuncts: 39
Disjuncts: 19
Disjuncts: 20
-- out/eval --
(struct){
a: (#list){
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/comprehensions/checkdefined.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Retain: 16

Unifications: 49
Conjuncts: 52
Disjuncts: 49
Disjuncts: 55
-- out/eval --
(struct){
xc: (#struct){
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/comprehensions/closed.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Retain: 6

Unifications: 58
Conjuncts: 104
Disjuncts: 71
Disjuncts: 73
-- out/eval --
Errors:
disallowed.vErr.d: field not allowed:
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/comprehensions/for.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Retain: 9

Unifications: 20
Conjuncts: 20
Disjuncts: 18
Disjuncts: 21
-- out/eval --
Errors:
k: invalid operand e (found int, want list or struct):
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/comprehensions/iferror.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Retain: 9

Unifications: 33
Conjuncts: 68
Disjuncts: 43
Disjuncts: 47
-- out/eval --
Errors:
issue1972.err1: conflicting values [] and {someCondition:_,patchs:[...{}],patchs,if someCondition {patchs:_}} (mismatched types list and struct):
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/comprehensions/issue1732.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Retain: 10

Unifications: 112
Conjuncts: 248
Disjuncts: 120
Disjuncts: 126
-- out/eval --
(struct){
networkingv1: (struct){
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/comprehensions/issue293.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Retain: 3

Unifications: 14
Conjuncts: 25
Disjuncts: 14
Disjuncts: 15
-- out/eval --
Errors:
z.x.f2: field not allowed:
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/comprehensions/issue837.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Retain: 11

Unifications: 114
Conjuncts: 291
Disjuncts: 164
Disjuncts: 173
-- out/eval --
Errors:
_params.hsize.$_instances: conflicting values 1 and {$_instances:(>=0|*1)} (mismatched types int and struct):
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/comprehensions/issue843.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Retain: 16

Unifications: 52
Conjuncts: 120
Disjuncts: 61
Disjuncts: 65
-- out/eval --
(struct){
#d1: (#struct){
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/comprehensions/nested.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Retain: 13

Unifications: 35
Conjuncts: 96
Disjuncts: 45
Disjuncts: 57
-- out/eval --
(struct){
service: (struct){
Expand Down
14 changes: 8 additions & 6 deletions cue/testdata/comprehensions/pushdown.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,6 @@ errorPropagation: { // TODO(broken)
}

-- issue2131.cue --
// TODO(broken)
import "path"

issue2131: tests: {
Expand Down Expand Up @@ -704,14 +703,14 @@ unifyDynamicReflectSuccess: {

-- out/eval/stats --
Leaks: 16
Freed: 384
Reused: 377
Freed: 387
Reused: 380
Allocs: 23
Retain: 69

Unifications: 386
Conjuncts: 622
Disjuncts: 393
Unifications: 389
Conjuncts: 649
Disjuncts: 432
-- out/eval --
Errors:
embed.fail1.p: field not allowed:
Expand Down Expand Up @@ -1364,12 +1363,15 @@ Result:
windows: (struct){
eg1: (struct){
in: (string){ "c:\\" }
out: (string){ "test" }
}
eg2: (struct){
in: (string){ "c:\\test" }
out: (string){ "test" }
}
eg3: (struct){
in: (string){ "c:\\test\\" }
out: (string){ "test" }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Retain: 3

Unifications: 7
Conjuncts: 13
Disjuncts: 7
Disjuncts: 9
-- out/eval --
(struct){
a: (struct){
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/cycle/023_reentrance.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Retain: 22

Unifications: 137
Conjuncts: 336
Disjuncts: 137
Disjuncts: 154
-- out/eval --
Errors:
structural cycle:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Retain: 1

Unifications: 4
Conjuncts: 6
Disjuncts: 4
Disjuncts: 5
-- out/eval --
Errors:
a.x: conflicting values "hey!?" and "hey":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Retain: 37

Unifications: 31
Conjuncts: 149
Disjuncts: 49
Disjuncts: 59
-- out/eval --
Errors:
xe1: 2 errors in empty disjunction:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Retain: 28

Unifications: 27
Conjuncts: 93
Disjuncts: 44
Disjuncts: 54
-- out/eval --
Errors:
xe1: 2 errors in empty disjunction:
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/cycle/builtins.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Retain: 26

Unifications: 37
Conjuncts: 61
Disjuncts: 37
Disjuncts: 57
-- out/eval --
(struct){
builtinCyclePerm0: (struct){
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/cycle/chain.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ Allocs: 64
Retain: 143

Unifications: 12118
Conjuncts: 67550
Disjuncts: 39375
Conjuncts: 67551
Disjuncts: 39452
-- out/eval --
(struct){
chain: (struct){
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/cycle/compbottom.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ Retain: 64

Unifications: 85
Conjuncts: 149
Disjuncts: 85
Disjuncts: 111
-- out/eval --
(struct){
simple: (struct){
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/cycle/compbottom2.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ Retain: 31

Unifications: 144
Conjuncts: 159
Disjuncts: 144
Disjuncts: 159
-- out/eval --
(struct){
self: (struct){
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/cycle/compbottomnofinal.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ Retain: 129

Unifications: 111
Conjuncts: 194
Disjuncts: 103
Disjuncts: 127
-- out/eval --
(struct){
minimal: (struct){
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/cycle/comprehension.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ Allocs: 60
Retain: 125

Unifications: 828
Conjuncts: 2518
Disjuncts: 1316
Conjuncts: 2539
Disjuncts: 1375
-- out/eval --
Errors:
selfReferential.insertionError.A: field foo3 not allowed by earlier comprehension or reference cycle
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/cycle/constraints.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ Retain: 4

Unifications: 143
Conjuncts: 321
Disjuncts: 143
Disjuncts: 147
-- out/eval --
Errors:
mutuallyTriggeringCycle.t1.x.c.b.b.b.b: structural cycle
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/cycle/evaluate.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Retain: 127

Unifications: 149
Conjuncts: 291
Disjuncts: 159
Disjuncts: 171
-- out/eval --
Errors:
closeCycle.a: structural cycle
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/cycle/expression.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Retain: 41

Unifications: 58
Conjuncts: 424
Disjuncts: 58
Disjuncts: 75
-- out/eval --
(struct){
t1: (struct){
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/cycle/inline.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Retain: 38

Unifications: 223
Conjuncts: 699
Disjuncts: 223
Disjuncts: 225
-- out/eval --
Errors:
structural cycle:
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/cycle/inline_non_recursive.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Retain: 102

Unifications: 680
Conjuncts: 2709
Disjuncts: 680
Disjuncts: 731
-- out/eval --
(struct){
ok1: (struct){
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/cycle/issue242.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Retain: 9

Unifications: 26
Conjuncts: 191
Disjuncts: 78
Disjuncts: 79
-- out/eval --
(struct){
size: (int){ 2 }
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/cycle/issue429.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Retain: 7

Unifications: 40
Conjuncts: 149
Disjuncts: 95
Disjuncts: 96
-- out/eval --
Errors:
er3.min: 2 errors in empty disjunction:
Expand Down
Loading

0 comments on commit 121894c

Please sign in to comment.