Skip to content

Commit cfbeb48

Browse files
committed
internal/core/adt: finalize in lookup in more cases
We add some more cases where we finalize when doing lookups. We really should always finalize, but this introduces some bugs. We finalize here to be able to detect that comparison against bottom properly. This brings behavior more in line with V2. Note that this is still not fully correct behavior, as we should report an error in these cases. elimination/disjunctions.txtar: Note the change in this file. V3 is arguably more correct, as it correctly reports an error, where V2 did not. Fixes #3836 Fixes #3838 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I756aafde66d1290e510b3ca2e035916263974bb9 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1211960 Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 470a02a commit cfbeb48

File tree

4 files changed

+87
-245
lines changed

4 files changed

+87
-245
lines changed

cue/testdata/cycle/compbottom2.txtar

Lines changed: 21 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -340,21 +340,7 @@ Unifications: 220
340340
Conjuncts: 279
341341
Disjuncts: 302
342342
-- out/evalalpha --
343-
Errors:
344-
_test.assert.res: invalid operand [
345-
if in.opt != _|_ {in.opt.foo},
346-
0,
347-
] (found list, want list or struct):
348-
./issue3838.cue:5:9
349-
_test.assert: 2 errors in empty disjunction::
350-
./issue3838.cue:23:12
351-
_test.assert.invoke: field not allowed:
352-
./issue3838.cue:23:12
353-
./issue3838.cue:26:18
354-
355-
Result:
356-
(_|_){
357-
// [eval]
343+
(struct){
358344
self: (struct){
359345
fail: (struct){
360346
a: (_|_){
@@ -390,33 +376,23 @@ Result:
390376
}
391377
issue3836: (struct){
392378
hidden: (#list){
393-
_Value: (struct){
379+
_Value: (_|_){
380+
// [incomplete] issue3836.hidden._Value.bar.type: cyclic reference to field type:
381+
// ./issue3836.cue:5:3
394382
foo?: (_){ _ }
395383
bar?: (struct){
396384
}
397385
out: (#list){
398386
}
399387
}
400388
}
401-
exposed: (struct){
402-
foo?: (_){ _ }
403-
bar?: (struct){
404-
}
405-
out: (#list){
406-
}
389+
exposed: (_|_){
390+
// [cycle] issue3836.exposed: circular dependency in evaluation of conditionals: (foo|bar) changed after evaluation:
391+
// ./issue3836.cue:15:6
407392
}
408393
}
409-
issue3838: (_|_){
410-
// [eval] _test.assert.res: invalid operand [
411-
// if in.opt != _|_ {in.opt.foo},
412-
// 0,
413-
// ] (found list, want list or struct):
414-
// ./issue3838.cue:5:9
415-
// _test.assert: 2 errors in empty disjunction::
416-
// ./issue3838.cue:23:12
417-
// _test.assert.invoke: field not allowed:
418-
// ./issue3838.cue:23:12
419-
// ./issue3838.cue:26:18
394+
issue3838: (bool){
395+
true
420396
#T: (#struct){
421397
subject: (#struct){
422398
in: (#struct){
@@ -640,23 +616,7 @@ Result:
640616
diff old new
641617
--- old
642618
+++ new
643-
@@ -1,15 +1,29 @@
644-
-(struct){
645-
+Errors:
646-
+_test.assert.res: invalid operand [
647-
+ if in.opt != _|_ {in.opt.foo},
648-
+ 0,
649-
+] (found list, want list or struct):
650-
+ ./issue3838.cue:5:9
651-
+_test.assert: 2 errors in empty disjunction::
652-
+ ./issue3838.cue:23:12
653-
+_test.assert.invoke: field not allowed:
654-
+ ./issue3838.cue:23:12
655-
+ ./issue3838.cue:26:18
656-
+
657-
+Result:
658-
+(_|_){
659-
+ // [eval]
619+
@@ -2,14 +2,14 @@
660620
self: (struct){
661621
fail: (struct){
662622
a: (_|_){
@@ -675,7 +635,7 @@ diff old new
675635
}
676636
}
677637
t2: (struct){
678-
@@ -21,8 +35,8 @@
638+
@@ -21,8 +21,8 @@
679639
}
680640
isNotConcrete: (struct){
681641
t1: (struct){
@@ -686,54 +646,26 @@ diff old new
686646
}
687647
}
688648
t2: (struct){
689-
@@ -34,19 +48,33 @@
690-
}
649+
@@ -35,10 +35,14 @@
691650
issue3836: (struct){
692651
hidden: (#list){
693-
- _Value: (_|_){
652+
_Value: (_|_){
694653
- // [cycle] issue3836.hidden._Value: circular dependency in evaluation of conditionals: (foo|bar) changed after evaluation:
695654
- // ./issue3836.cue:5:7
696655
- }
697656
- 0: (string){ "bar is set" }
698-
- }
699-
- exposed: (_|_){
700-
- // [cycle] issue3836.exposed: circular dependency in evaluation of conditionals: (foo|bar) changed after evaluation:
701-
- // ./issue3836.cue:15:6
702-
- }
703-
- }
704-
- issue3838: (bool){
705-
- true
706-
+ _Value: (struct){
657+
+ // [incomplete] issue3836.hidden._Value.bar.type: cyclic reference to field type:
658+
+ // ./issue3836.cue:5:3
707659
+ foo?: (_){ _ }
708660
+ bar?: (struct){
709661
+ }
710662
+ out: (#list){
711663
+ }
712664
+ }
713-
+ }
714-
+ exposed: (struct){
715-
+ foo?: (_){ _ }
716-
+ bar?: (struct){
717-
+ }
718-
+ out: (#list){
719-
+ }
720-
+ }
721-
+ }
722-
+ issue3838: (_|_){
723-
+ // [eval] _test.assert.res: invalid operand [
724-
+ // if in.opt != _|_ {in.opt.foo},
725-
+ // 0,
726-
+ // ] (found list, want list or struct):
727-
+ // ./issue3838.cue:5:9
728-
+ // _test.assert: 2 errors in empty disjunction::
729-
+ // ./issue3838.cue:23:12
730-
+ // _test.assert.invoke: field not allowed:
731-
+ // ./issue3838.cue:23:12
732-
+ // ./issue3838.cue:26:18
733-
#T: (#struct){
734-
subject: (#struct){
735-
in: (#struct){
736-
@@ -83,12 +111,12 @@
665+
}
666+
exposed: (_|_){
667+
// [cycle] issue3836.exposed: circular dependency in evaluation of conditionals: (foo|bar) changed after evaluation:
668+
@@ -83,12 +87,12 @@
737669
}
738670
mutualCycleFail: (struct){
739671
b: (_|_){
@@ -752,7 +684,7 @@ diff old new
752684
}
753685
}
754686
brokenCycleSuccess: (struct){
755-
@@ -229,17 +257,19 @@
687+
@@ -229,17 +233,19 @@
756688
ret?: (_){ _ }
757689
}
758690
expr: (#struct){
@@ -777,7 +709,7 @@ diff old new
777709
}
778710
brokenCycleSuccess: (struct){
779711
#E: (#struct){
780-
@@ -248,8 +278,12 @@
712+
@@ -248,8 +254,12 @@
781713
}
782714
}
783715
doubleAddfail: (_|_){

cue/testdata/cycle/inline.txtar

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ Reused: 0
401401
Allocs: 332
402402
Retain: 0
403403

404-
Unifications: 252
405-
Conjuncts: 635
404+
Unifications: 253
405+
Conjuncts: 639
406406
Disjuncts: 0
407407
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
408408
diff old new
@@ -423,8 +423,8 @@ diff old new
423423
-Unifications: 539
424424
-Conjuncts: 1663
425425
-Disjuncts: 943
426-
+Unifications: 252
427-
+Conjuncts: 635
426+
+Unifications: 253
427+
+Conjuncts: 639
428428
+Disjuncts: 0
429429
-- out/eval/stats --
430430
Leaks: 286

0 commit comments

Comments
 (0)