Skip to content

Commit

Permalink
internal/core/adt: eliminate disjuncts for incomplete errors
Browse files Browse the repository at this point in the history
Also incomplete errors should eliminate disjunctions, even when
recursive.

Fixes #1924

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I804fd5f15c3c1faa58c4b856afb3c99f5921e109
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/543427
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Paul Jolly <paul@myitcv.io>
  • Loading branch information
mpvl committed Sep 15, 2022
1 parent 6551ea5 commit c556a19
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 113 deletions.
52 changes: 26 additions & 26 deletions cue/testdata/comprehensions/pushdown.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -1072,19 +1072,19 @@ Result:
}
}
}
E: (struct){ |((struct){
e: (bool){ bool }
f: (_|_){
// [incomplete] voidEliminationSuccess.derefDisj1.E.f: operand e of '!' not concrete (was bool):
// ./in.cue:404:7
}
}, (struct){
g: (bool){ bool }
h: (_|_){
// [incomplete] voidEliminationSuccess.derefDisj1.E.h: operand g of '!' not concrete (was bool):
// ./in.cue:407:7
}
}) }
E: (_|_){
// [incomplete] voidEliminationSuccess.derefDisj1.E: 2 errors in empty disjunction::
// ./in.cue:394:28
// voidEliminationSuccess.derefDisj1.E.f: operand e of '!' not concrete (was bool):
// ./in.cue:404:7
// voidEliminationSuccess.derefDisj1.E.h: operand g of '!' not concrete (was bool):
// ./in.cue:407:7
g: (bool){ bool }
h: (_|_){
// [incomplete] voidEliminationSuccess.derefDisj1.E.h: operand g of '!' not concrete (was bool):
// ./in.cue:407:7
}
}
}
derefDisj2: (struct){
a: (struct){
Expand All @@ -1093,19 +1093,19 @@ Result:
}
}
}
E: (struct){ |((struct){
e: (bool){ bool }
f: (_|_){
// [incomplete] voidEliminationSuccess.derefDisj2.E.f: operand e of '!' not concrete (was bool):
// ./in.cue:422:7
}
}, (struct){
g: (bool){ bool }
h: (_|_){
// [incomplete] voidEliminationSuccess.derefDisj2.E.h: operand g of '!' not concrete (was bool):
// ./in.cue:425:7
}
}) }
E: (_|_){
// [incomplete] voidEliminationSuccess.derefDisj2.E: 2 errors in empty disjunction::
// ./in.cue:412:28
// voidEliminationSuccess.derefDisj2.E.f: operand e of '!' not concrete (was bool):
// ./in.cue:422:7
// voidEliminationSuccess.derefDisj2.E.h: operand g of '!' not concrete (was bool):
// ./in.cue:425:7
g: (bool){ bool }
h: (_|_){
// [incomplete] voidEliminationSuccess.derefDisj2.E.h: operand g of '!' not concrete (was bool):
// ./in.cue:425:7
}
}
}
bulk1: (struct){
a: (struct){
Expand Down
118 changes: 67 additions & 51 deletions cue/testdata/disjunctions/elimination.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,20 @@ noChildError: t4: {
o: #D & {b: "test"}
#D: {a: null} | {b: string} | {c: #D }
}


issue1924: t1: {
m: a: 2
x: *[m.b] | 2
}
issue1924: t2: {
m: a: 2
x: *{v: m.b} | 3
}
issue1924: t3: {
m: a: 2
x: *m.b | 1
}
-- out/eval --
(struct){
disambiguateClosed: (struct){
Expand Down Expand Up @@ -289,26 +303,10 @@ noChildError: t4: {
a: (struct){
n1: (struct){
p1: (struct){
x: ((null|struct)){ |((struct){
a: (_|_){
// [incomplete] nestedNonMonotonic.incomplete.a.n1.p1.x.a: invalid value {c:1} (does not satisfy struct.MinFields(2)): len(fields) < MinFields(2) (1 < 2):
// ./in.cue:84:12
// ./in.cue:84:29
// ./in.cue:85:9
c: (int){ 1 }
}
}, (null){ null }) }
x: (null){ null }
}
p2: (struct){
x: ((null|struct)){ |((struct){
a: (_|_){
// [incomplete] nestedNonMonotonic.incomplete.a.n1.p2.x.a: invalid value {c:1} (does not satisfy struct.MinFields(2)): len(fields) < MinFields(2) (1 < 2):
// ./in.cue:90:12
// ./in.cue:89:9
// ./in.cue:90:29
c: (int){ 1 }
}
}, (null){ null }) }
x: (null){ null }
}
}
n2: (struct){
Expand Down Expand Up @@ -343,43 +341,13 @@ noChildError: t4: {
b: (struct){
n1: (struct){
p1: (struct){
x: ((null|struct)){ |((struct){
a: (_|_){
// [incomplete] nestedNonMonotonic.incomplete.b.n1.p1.x.a: invalid value {c:1,d:1} (does not satisfy struct.MinFields(3)): len(fields) < MinFields(3) (2 < 3):
// ./in.cue:104:12
// ./in.cue:104:29
// ./in.cue:105:9
// ./in.cue:106:9
c: (int){ 1 }
d: (int){ 1 }
}
}, (null){ null }) }
x: (null){ null }
}
p2: (struct){
x: ((null|struct)){ |((struct){
a: (_|_){
// [incomplete] nestedNonMonotonic.incomplete.b.n1.p2.x.a: invalid value {c:1,d:1} (does not satisfy struct.MinFields(3)): len(fields) < MinFields(3) (2 < 3):
// ./in.cue:111:12
// ./in.cue:110:9
// ./in.cue:111:29
// ./in.cue:112:9
c: (int){ 1 }
d: (int){ 1 }
}
}, (null){ null }) }
x: (null){ null }
}
p3: (struct){
x: ((null|struct)){ |((struct){
a: (_|_){
// [incomplete] nestedNonMonotonic.incomplete.b.n1.p3.x.a: invalid value {c:1,d:1} (does not satisfy struct.MinFields(3)): len(fields) < MinFields(3) (2 < 3):
// ./in.cue:118:12
// ./in.cue:116:9
// ./in.cue:117:9
// ./in.cue:118:29
c: (int){ 1 }
d: (int){ 1 }
}
}, (null){ null }) }
x: (null){ null }
}
}
n2: (struct){
Expand Down Expand Up @@ -598,6 +566,26 @@ noChildError: t4: {
}) }
}
}
issue1924: (struct){
t1: (struct){
m: (struct){
a: (int){ 2 }
}
x: (int){ 2 }
}
t2: (struct){
m: (struct){
a: (int){ 2 }
}
x: (int){ 3 }
}
t3: (struct){
m: (struct){
a: (int){ 2 }
}
x: (int){ 1 }
}
}
}
-- out/compile --
--- in.cue
Expand Down Expand Up @@ -1227,4 +1215,32 @@ noChildError: t4: {
})
}
}
issue1924: {
t1: {
m: {
a: 2
}
x: (*[
〈1;m〉.b,
]|2)
}
}
issue1924: {
t2: {
m: {
a: 2
}
x: (*{
v: 〈1;m〉.b
}|3)
}
}
issue1924: {
t3: {
m: {
a: 2
}
x: (*〈0;m〉.b|1)
}
}
}
3 changes: 0 additions & 3 deletions internal/core/adt/disjunct.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ func (n *nodeContext) expandDisjuncts(
// Perhaps introduce an Err() method.
err = x.ChildErrors
}
if err.IsIncomplete() {
break
}
if err != nil {
parent.disjunctErrs = append(parent.disjunctErrs, err)
}
Expand Down
39 changes: 6 additions & 33 deletions internal/core/export/testdata/main/let.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ y: Y & Y_1
[incomplete d run2 a]
[unresolvedDisjunction]
[unresolvedDisjunction #TypePrimitive]
[unresolvedDisjunction #TypePrimitive _args]
[unresolvedDisjunction #TypePrimitive _args required]
[unresolvedDisjunction #TypePrimitive "*"]
[unresolvedDisjunction #TypeBool]
[unresolvedDisjunction #TypeBool default]
[unresolvedDisjunction #TypeBool _args]
Expand Down Expand Up @@ -532,19 +535,10 @@ y: Y & Y_1
}
unresolvedDisjunction: {
#TypePrimitive: {
let Args = _args
{
"*": {}
} | {
bool: #TypeBool & {
_args: {
required: Args.required
}
}
}
_args: {
required: bool
}
"*": {}
}
#TypeBool: {
let Args_1 = _args
Expand Down Expand Up @@ -738,19 +732,10 @@ y: Y & Y_1
}
unresolvedDisjunction: {
#TypePrimitive: {
let Args = _args
{
"*": {}
} | {
bool: #TypeBool & {
_args: {
required: Args.required
}
}
}
_args: {
required: bool
}
"*": {}
}
#TypeBool: {
let Args_1 = _args
Expand Down Expand Up @@ -862,19 +847,7 @@ y: Y & Y_1
}
unresolvedDisjunction: {
#TypePrimitive: {
let Args = _args
{
"*": {}
} | {
bool: #TypeBool & {
_args: {
required: Args.required
}
}
}
_args: {
required: bool
}
"*": {}
}
#TypeBool: {
let Args_1 = _args
Expand Down

0 comments on commit c556a19

Please sign in to comment.