Skip to content

Commit b6a2637

Browse files
committed
internal/core/adt: fix missing field error message
It used to be that a "NotPresent" arc was indicative of a cyclic evaluation. Now it is just not present. Adjust the error message accordingly. Issue #3060 Issue #2884 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: If9207745dc8daced4bc01818a88ce5a21d049eab Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1194078 Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 71220e6 commit b6a2637

File tree

4 files changed

+15
-32
lines changed

4 files changed

+15
-32
lines changed

cue/testdata/cycle/compbottomnofinal.txtar

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ Disjuncts: 215
484484
host: (string){ "mod.test" }
485485
}
486486
X: (_|_){
487-
// [incomplete] large.p1.X: cyclic reference to field port:
487+
// [incomplete] large.p1.X: undefined field: port:
488488
// ./in.cue:199:33
489489
}
490490
#X: (_|_){
@@ -494,13 +494,13 @@ Disjuncts: 215
494494
host: (string){ "mod.test" }
495495
}
496496
#Y: (_|_){
497-
// [incomplete] large.p1.X: cyclic reference to field port:
497+
// [incomplete] large.p1.X: undefined field: port:
498498
// ./in.cue:199:33
499499
}
500500
}
501501
p2: (struct){
502502
X: (_|_){
503-
// [incomplete] large.p2.X: cyclic reference to field port:
503+
// [incomplete] large.p2.X: undefined field: port:
504504
// ./in.cue:235:33
505505
}
506506
Y: (struct){
@@ -520,7 +520,7 @@ Disjuncts: 215
520520
}
521521
p3: (struct){
522522
X: (_|_){
523-
// [incomplete] large.p3.X: cyclic reference to field port:
523+
// [incomplete] large.p3.X: undefined field: port:
524524
// ./in.cue:276:33
525525
}
526526
#X: (_|_){
@@ -540,7 +540,7 @@ Disjuncts: 215
540540
}
541541
p4: (struct){
542542
X: (_|_){
543-
// [incomplete] large.p4.X: cyclic reference to field port:
543+
// [incomplete] large.p4.X: undefined field: port:
544544
// ./in.cue:317:33
545545
}
546546
#X: (_|_){
@@ -845,7 +845,7 @@ diff old new
845845
+ host: (string){ "mod.test" }
846846
+ }
847847
+ X: (_|_){
848-
+ // [incomplete] large.p1.X: cyclic reference to field port:
848+
+ // [incomplete] large.p1.X: undefined field: port:
849849
+ // ./in.cue:199:33
850850
+ }
851851
+ #X: (_|_){
@@ -855,13 +855,13 @@ diff old new
855855
+ host: (string){ "mod.test" }
856856
+ }
857857
+ #Y: (_|_){
858-
+ // [incomplete] large.p1.X: cyclic reference to field port:
858+
+ // [incomplete] large.p1.X: undefined field: port:
859859
+ // ./in.cue:199:33
860860
+ }
861861
+ }
862862
+ p2: (struct){
863863
+ X: (_|_){
864-
+ // [incomplete] large.p2.X: cyclic reference to field port:
864+
+ // [incomplete] large.p2.X: undefined field: port:
865865
+ // ./in.cue:235:33
866866
+ }
867867
+ Y: (struct){
@@ -881,7 +881,7 @@ diff old new
881881
+ }
882882
+ p3: (struct){
883883
+ X: (_|_){
884-
+ // [incomplete] large.p3.X: cyclic reference to field port:
884+
+ // [incomplete] large.p3.X: undefined field: port:
885885
+ // ./in.cue:276:33
886886
+ }
887887
+ #X: (_|_){
@@ -901,7 +901,7 @@ diff old new
901901
+ }
902902
+ p4: (struct){
903903
+ X: (_|_){
904-
+ // [incomplete] large.p4.X: cyclic reference to field port:
904+
+ // [incomplete] large.p4.X: undefined field: port:
905905
+ // ./in.cue:317:33
906906
+ }
907907
+ #X: (_|_){

cue/testdata/cycle/comprehension.txtar

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -666,12 +666,12 @@ Result:
666666
}
667667
}
668668
fail: (_|_){
669-
// [incomplete] selfReferential.fail.b: cyclic reference to field x:
669+
// [incomplete] selfReferential.fail.b: undefined field: x:
670670
// ./in.cue:300:7
671671
a: (struct){
672672
}
673673
b: (_|_){
674-
// [incomplete] selfReferential.fail.b: cyclic reference to field x:
674+
// [incomplete] selfReferential.fail.b: undefined field: x:
675675
// ./in.cue:300:7
676676
}
677677
}
@@ -952,7 +952,7 @@ diff old new
952952
}
953953
}
954954
}
955-
@@ -127,208 +181,269 @@
955+
@@ -127,116 +181,165 @@
956956
insertionError: (_|_){
957957
// [eval]
958958
A: (_|_){
@@ -1227,16 +1227,7 @@ diff old new
12271227
}
12281228
}
12291229
}
1230-
fail: (_|_){
1231-
- // [incomplete] selfReferential.fail.b: undefined field: x:
1232-
+ // [incomplete] selfReferential.fail.b: cyclic reference to field x:
1233-
// ./in.cue:300:7
1234-
a: (struct){
1235-
}
1236-
b: (_|_){
1237-
- // [incomplete] selfReferential.fail.b: undefined field: x:
1238-
+ // [incomplete] selfReferential.fail.b: cyclic reference to field x:
1239-
// ./in.cue:300:7
1230+
@@ -251,84 +354,96 @@
12401231
}
12411232
}
12421233
}

cue/types_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -806,17 +806,13 @@ func TestFields(t *testing.T) {
806806
if step1.value > 100 {
807807
}`,
808808
err: "undefined field: value",
809-
810-
todoV3: true,
811809
}, {
812810
opts: []Option{Concrete(true)},
813811
value: `
814812
step1: {}
815813
if step1.value > 100 {
816814
}`,
817815
err: "undefined field: value",
818-
819-
todoV3: true,
820816
}, {
821817
value: `{a!: 1, b?: 2, c: 3}`,
822818
err: "a: field is required but not present",
@@ -835,10 +831,6 @@ func TestFields(t *testing.T) {
835831
}}
836832
for _, tc := range testCases {
837833
runMatrix(t, tc.value, func(t *testing.T, cfg *evalConfig) {
838-
if tc.todoV3 {
839-
TODO_V3(t, cfg)
840-
}
841-
842834
obj := cfg.getValue(t, tc.value)
843835

844836
iter, err := obj.Fields(tc.opts...)

internal/core/adt/unify.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ func (v *Vertex) lookup(c *OpContext, pos token.Pos, f Feature, flags combinedFl
710710
return nil
711711

712712
case ArcNotPresent:
713-
v.reportFieldCycleError(c, pos, f)
713+
v.reportFieldIndexError(c, pos, f)
714714
return nil
715715

716716
case ArcPending:

0 commit comments

Comments
 (0)