Skip to content

Commit

Permalink
internal/core/adt: fix missing field error message
Browse files Browse the repository at this point in the history
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 <mpvl@gmail.com>
Change-Id: If9207745dc8daced4bc01818a88ce5a21d049eab
  • Loading branch information
mpvl committed Apr 30, 2024
1 parent db5100b commit 17ae397
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 32 deletions.
20 changes: 10 additions & 10 deletions cue/testdata/cycle/compbottomnofinal.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ Disjuncts: 215
host: (string){ "mod.test" }
}
X: (_|_){
// [incomplete] large.p1.X: cyclic reference to field port:
// [incomplete] large.p1.X: undefined field: port:
// ./in.cue:199:33
}
#X: (_|_){
Expand All @@ -494,13 +494,13 @@ Disjuncts: 215
host: (string){ "mod.test" }
}
#Y: (_|_){
// [incomplete] large.p1.X: cyclic reference to field port:
// [incomplete] large.p1.X: undefined field: port:
// ./in.cue:199:33
}
}
p2: (struct){
X: (_|_){
// [incomplete] large.p2.X: cyclic reference to field port:
// [incomplete] large.p2.X: undefined field: port:
// ./in.cue:235:33
}
Y: (struct){
Expand All @@ -520,7 +520,7 @@ Disjuncts: 215
}
p3: (struct){
X: (_|_){
// [incomplete] large.p3.X: cyclic reference to field port:
// [incomplete] large.p3.X: undefined field: port:
// ./in.cue:276:33
}
#X: (_|_){
Expand All @@ -540,7 +540,7 @@ Disjuncts: 215
}
p4: (struct){
X: (_|_){
// [incomplete] large.p4.X: cyclic reference to field port:
// [incomplete] large.p4.X: undefined field: port:
// ./in.cue:317:33
}
#X: (_|_){
Expand Down Expand Up @@ -845,7 +845,7 @@ diff old new
+ host: (string){ "mod.test" }
+ }
+ X: (_|_){
+ // [incomplete] large.p1.X: cyclic reference to field port:
+ // [incomplete] large.p1.X: undefined field: port:
+ // ./in.cue:199:33
+ }
+ #X: (_|_){
Expand All @@ -855,13 +855,13 @@ diff old new
+ host: (string){ "mod.test" }
+ }
+ #Y: (_|_){
+ // [incomplete] large.p1.X: cyclic reference to field port:
+ // [incomplete] large.p1.X: undefined field: port:
+ // ./in.cue:199:33
+ }
+ }
+ p2: (struct){
+ X: (_|_){
+ // [incomplete] large.p2.X: cyclic reference to field port:
+ // [incomplete] large.p2.X: undefined field: port:
+ // ./in.cue:235:33
+ }
+ Y: (struct){
Expand All @@ -881,7 +881,7 @@ diff old new
+ }
+ p3: (struct){
+ X: (_|_){
+ // [incomplete] large.p3.X: cyclic reference to field port:
+ // [incomplete] large.p3.X: undefined field: port:
+ // ./in.cue:276:33
+ }
+ #X: (_|_){
Expand All @@ -901,7 +901,7 @@ diff old new
+ }
+ p4: (struct){
+ X: (_|_){
+ // [incomplete] large.p4.X: cyclic reference to field port:
+ // [incomplete] large.p4.X: undefined field: port:
+ // ./in.cue:317:33
+ }
+ #X: (_|_){
Expand Down
17 changes: 4 additions & 13 deletions cue/testdata/cycle/comprehension.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -666,12 +666,12 @@ Result:
}
}
fail: (_|_){
// [incomplete] selfReferential.fail.b: cyclic reference to field x:
// [incomplete] selfReferential.fail.b: undefined field: x:
// ./in.cue:300:7
a: (struct){
}
b: (_|_){
// [incomplete] selfReferential.fail.b: cyclic reference to field x:
// [incomplete] selfReferential.fail.b: undefined field: x:
// ./in.cue:300:7
}
}
Expand Down Expand Up @@ -952,7 +952,7 @@ diff old new
}
}
}
@@ -127,208 +181,269 @@
@@ -127,116 +181,165 @@
insertionError: (_|_){
// [eval]
A: (_|_){
Expand Down Expand Up @@ -1227,16 +1227,7 @@ diff old new
}
}
}
fail: (_|_){
- // [incomplete] selfReferential.fail.b: undefined field: x:
+ // [incomplete] selfReferential.fail.b: cyclic reference to field x:
// ./in.cue:300:7
a: (struct){
}
b: (_|_){
- // [incomplete] selfReferential.fail.b: undefined field: x:
+ // [incomplete] selfReferential.fail.b: cyclic reference to field x:
// ./in.cue:300:7
@@ -251,84 +354,96 @@
}
}
}
Expand Down
8 changes: 0 additions & 8 deletions cue/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -806,17 +806,13 @@ func TestFields(t *testing.T) {
if step1.value > 100 {
}`,
err: "undefined field: value",

todoV3: true,
}, {
opts: []Option{Concrete(true)},
value: `
step1: {}
if step1.value > 100 {
}`,
err: "undefined field: value",

todoV3: true,
}, {
value: `{a!: 1, b?: 2, c: 3}`,
err: "a: field is required but not present",
Expand All @@ -835,10 +831,6 @@ func TestFields(t *testing.T) {
}}
for _, tc := range testCases {
runMatrix(t, tc.value, func(t *testing.T, cfg *evalConfig) {
if tc.todoV3 {
TODO_V3(t, cfg)
}

obj := cfg.getValue(t, tc.value)

iter, err := obj.Fields(tc.opts...)
Expand Down
2 changes: 1 addition & 1 deletion internal/core/adt/unify.go
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ func (v *Vertex) lookup(c *OpContext, pos token.Pos, f Feature, flags combinedFl
return nil

case ArcNotPresent:
v.reportFieldCycleError(c, pos, f)
v.reportFieldIndexError(c, pos, f)
return nil

case ArcPending:
Expand Down

0 comments on commit 17ae397

Please sign in to comment.