this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/core/adt: eliminate disjuncts for incomplete errors

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>

+99 -113
+26 -26
cue/testdata/comprehensions/pushdown.txtar
··· 1072 1072 } 1073 1073 } 1074 1074 } 1075 - E: (struct){ |((struct){ 1076 - e: (bool){ bool } 1077 - f: (_|_){ 1078 - // [incomplete] voidEliminationSuccess.derefDisj1.E.f: operand e of '!' not concrete (was bool): 1079 - // ./in.cue:404:7 1080 - } 1081 - }, (struct){ 1082 - g: (bool){ bool } 1083 - h: (_|_){ 1084 - // [incomplete] voidEliminationSuccess.derefDisj1.E.h: operand g of '!' not concrete (was bool): 1085 - // ./in.cue:407:7 1086 - } 1087 - }) } 1075 + E: (_|_){ 1076 + // [incomplete] voidEliminationSuccess.derefDisj1.E: 2 errors in empty disjunction:: 1077 + // ./in.cue:394:28 1078 + // voidEliminationSuccess.derefDisj1.E.f: operand e of '!' not concrete (was bool): 1079 + // ./in.cue:404:7 1080 + // voidEliminationSuccess.derefDisj1.E.h: operand g of '!' not concrete (was bool): 1081 + // ./in.cue:407:7 1082 + g: (bool){ bool } 1083 + h: (_|_){ 1084 + // [incomplete] voidEliminationSuccess.derefDisj1.E.h: operand g of '!' not concrete (was bool): 1085 + // ./in.cue:407:7 1086 + } 1087 + } 1088 1088 } 1089 1089 derefDisj2: (struct){ 1090 1090 a: (struct){ ··· 1093 1093 } 1094 1094 } 1095 1095 } 1096 - E: (struct){ |((struct){ 1097 - e: (bool){ bool } 1098 - f: (_|_){ 1099 - // [incomplete] voidEliminationSuccess.derefDisj2.E.f: operand e of '!' not concrete (was bool): 1100 - // ./in.cue:422:7 1101 - } 1102 - }, (struct){ 1103 - g: (bool){ bool } 1104 - h: (_|_){ 1105 - // [incomplete] voidEliminationSuccess.derefDisj2.E.h: operand g of '!' not concrete (was bool): 1106 - // ./in.cue:425:7 1107 - } 1108 - }) } 1096 + E: (_|_){ 1097 + // [incomplete] voidEliminationSuccess.derefDisj2.E: 2 errors in empty disjunction:: 1098 + // ./in.cue:412:28 1099 + // voidEliminationSuccess.derefDisj2.E.f: operand e of '!' not concrete (was bool): 1100 + // ./in.cue:422:7 1101 + // voidEliminationSuccess.derefDisj2.E.h: operand g of '!' not concrete (was bool): 1102 + // ./in.cue:425:7 1103 + g: (bool){ bool } 1104 + h: (_|_){ 1105 + // [incomplete] voidEliminationSuccess.derefDisj2.E.h: operand g of '!' not concrete (was bool): 1106 + // ./in.cue:425:7 1107 + } 1108 + } 1109 1109 } 1110 1110 bulk1: (struct){ 1111 1111 a: (struct){
+67 -51
cue/testdata/disjunctions/elimination.txtar
··· 211 211 o: #D & {b: "test"} 212 212 #D: {a: null} | {b: string} | {c: #D } 213 213 } 214 + 215 + 216 + issue1924: t1: { 217 + m: a: 2 218 + x: *[m.b] | 2 219 + } 220 + issue1924: t2: { 221 + m: a: 2 222 + x: *{v: m.b} | 3 223 + } 224 + issue1924: t3: { 225 + m: a: 2 226 + x: *m.b | 1 227 + } 214 228 -- out/eval -- 215 229 (struct){ 216 230 disambiguateClosed: (struct){ ··· 289 303 a: (struct){ 290 304 n1: (struct){ 291 305 p1: (struct){ 292 - x: ((null|struct)){ |((struct){ 293 - a: (_|_){ 294 - // [incomplete] nestedNonMonotonic.incomplete.a.n1.p1.x.a: invalid value {c:1} (does not satisfy struct.MinFields(2)): len(fields) < MinFields(2) (1 < 2): 295 - // ./in.cue:84:12 296 - // ./in.cue:84:29 297 - // ./in.cue:85:9 298 - c: (int){ 1 } 299 - } 300 - }, (null){ null }) } 306 + x: (null){ null } 301 307 } 302 308 p2: (struct){ 303 - x: ((null|struct)){ |((struct){ 304 - a: (_|_){ 305 - // [incomplete] nestedNonMonotonic.incomplete.a.n1.p2.x.a: invalid value {c:1} (does not satisfy struct.MinFields(2)): len(fields) < MinFields(2) (1 < 2): 306 - // ./in.cue:90:12 307 - // ./in.cue:89:9 308 - // ./in.cue:90:29 309 - c: (int){ 1 } 310 - } 311 - }, (null){ null }) } 309 + x: (null){ null } 312 310 } 313 311 } 314 312 n2: (struct){ ··· 343 341 b: (struct){ 344 342 n1: (struct){ 345 343 p1: (struct){ 346 - x: ((null|struct)){ |((struct){ 347 - a: (_|_){ 348 - // [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): 349 - // ./in.cue:104:12 350 - // ./in.cue:104:29 351 - // ./in.cue:105:9 352 - // ./in.cue:106:9 353 - c: (int){ 1 } 354 - d: (int){ 1 } 355 - } 356 - }, (null){ null }) } 344 + x: (null){ null } 357 345 } 358 346 p2: (struct){ 359 - x: ((null|struct)){ |((struct){ 360 - a: (_|_){ 361 - // [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): 362 - // ./in.cue:111:12 363 - // ./in.cue:110:9 364 - // ./in.cue:111:29 365 - // ./in.cue:112:9 366 - c: (int){ 1 } 367 - d: (int){ 1 } 368 - } 369 - }, (null){ null }) } 347 + x: (null){ null } 370 348 } 371 349 p3: (struct){ 372 - x: ((null|struct)){ |((struct){ 373 - a: (_|_){ 374 - // [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): 375 - // ./in.cue:118:12 376 - // ./in.cue:116:9 377 - // ./in.cue:117:9 378 - // ./in.cue:118:29 379 - c: (int){ 1 } 380 - d: (int){ 1 } 381 - } 382 - }, (null){ null }) } 350 + x: (null){ null } 383 351 } 384 352 } 385 353 n2: (struct){ ··· 596 564 }, (#struct){ 597 565 b: (string){ string } 598 566 }) } 567 + } 568 + } 569 + issue1924: (struct){ 570 + t1: (struct){ 571 + m: (struct){ 572 + a: (int){ 2 } 573 + } 574 + x: (int){ 2 } 575 + } 576 + t2: (struct){ 577 + m: (struct){ 578 + a: (int){ 2 } 579 + } 580 + x: (int){ 3 } 581 + } 582 + t3: (struct){ 583 + m: (struct){ 584 + a: (int){ 2 } 585 + } 586 + x: (int){ 1 } 599 587 } 600 588 } 601 589 } ··· 1225 1213 }|{ 1226 1214 c: 〈1;#D〉 1227 1215 }) 1216 + } 1217 + } 1218 + issue1924: { 1219 + t1: { 1220 + m: { 1221 + a: 2 1222 + } 1223 + x: (*[ 1224 + 〈1;m〉.b, 1225 + ]|2) 1226 + } 1227 + } 1228 + issue1924: { 1229 + t2: { 1230 + m: { 1231 + a: 2 1232 + } 1233 + x: (*{ 1234 + v: 〈1;m〉.b 1235 + }|3) 1236 + } 1237 + } 1238 + issue1924: { 1239 + t3: { 1240 + m: { 1241 + a: 2 1242 + } 1243 + x: (*〈0;m〉.b|1) 1228 1244 } 1229 1245 } 1230 1246 }
-3
internal/core/adt/disjunct.go
··· 167 167 // Perhaps introduce an Err() method. 168 168 err = x.ChildErrors 169 169 } 170 - if err.IsIncomplete() { 171 - break 172 - } 173 170 if err != nil { 174 171 parent.disjunctErrs = append(parent.disjunctErrs, err) 175 172 }
+6 -33
internal/core/export/testdata/main/let.txtar
··· 301 301 [incomplete d run2 a] 302 302 [unresolvedDisjunction] 303 303 [unresolvedDisjunction #TypePrimitive] 304 + [unresolvedDisjunction #TypePrimitive _args] 305 + [unresolvedDisjunction #TypePrimitive _args required] 306 + [unresolvedDisjunction #TypePrimitive "*"] 304 307 [unresolvedDisjunction #TypeBool] 305 308 [unresolvedDisjunction #TypeBool default] 306 309 [unresolvedDisjunction #TypeBool _args] ··· 532 535 } 533 536 unresolvedDisjunction: { 534 537 #TypePrimitive: { 535 - let Args = _args 536 - { 537 - "*": {} 538 - } | { 539 - bool: #TypeBool & { 540 - _args: { 541 - required: Args.required 542 - } 543 - } 544 - } 545 538 _args: { 546 539 required: bool 547 540 } 541 + "*": {} 548 542 } 549 543 #TypeBool: { 550 544 let Args_1 = _args ··· 738 732 } 739 733 unresolvedDisjunction: { 740 734 #TypePrimitive: { 741 - let Args = _args 742 - { 743 - "*": {} 744 - } | { 745 - bool: #TypeBool & { 746 - _args: { 747 - required: Args.required 748 - } 749 - } 750 - } 751 735 _args: { 752 736 required: bool 753 737 } 738 + "*": {} 754 739 } 755 740 #TypeBool: { 756 741 let Args_1 = _args ··· 862 847 } 863 848 unresolvedDisjunction: { 864 849 #TypePrimitive: { 865 - let Args = _args 866 - { 867 - "*": {} 868 - } | { 869 - bool: #TypeBool & { 870 - _args: { 871 - required: Args.required 872 - } 873 - } 874 - } 875 - _args: { 876 - required: bool 877 - } 850 + "*": {} 878 851 } 879 852 #TypeBool: { 880 853 let Args_1 = _args