Skip to content

Commit

Permalink
cue: move field name to end of error message
Browse files Browse the repository at this point in the history
This avoid ambiguities for certain field names.

Fixes #956

Change-Id: Ia6009da4354efcd2aef7756528d50eaac8eb5bd3
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9723
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
mpvl committed May 10, 2021
1 parent a31dd01 commit 3fdad16
Show file tree
Hide file tree
Showing 33 changed files with 135 additions and 136 deletions.
6 changes: 3 additions & 3 deletions cmd/cue/cmd/testdata/script/vet_embed.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ a: 1
e: 2

-- expect-foo --
field c not allowed:
field not allowed: c:
./foo.yaml:2:2
./schema.cue:1:1
./schema.cue:3:7
./schema.cue:7:1
-- expect-stream --
field d not allowed:
field not allowed: d:
./schema.cue:1:1
./schema.cue:3:7
./schema.cue:7:1
./stream.yaml:2:2
-- expect-stream --
field d not allowed:
field not allowed: d:
./schema.cue:1:1
./schema.cue:3:7
./schema.cue:7:1
Expand Down
2 changes: 1 addition & 1 deletion cmd/cue/cmd/testdata/script/vet_expr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmp stderr expect-stderr

-- expect-stderr --
translations.hello.lang: incomplete value string
field skip not allowed:
field not allowed: skip:
./data.yaml:20:1
./vet.cue:1:1
./vet.cue:1:8
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/builtins/closed.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ withSubfields: {

-- out/eval --
Errors:
b: field x not allowed:
b: field not allowed: x:
./in.cue:1:10
./in.cue:5:4
./in.cue:5:10
Expand All @@ -63,7 +63,7 @@ Result:
b: (int){ int }
}
x: (_|_){
// [eval] b: field x not allowed:
// [eval] b: field not allowed: x:
// ./in.cue:1:10
// ./in.cue:5:4
// ./in.cue:5:10
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/builtins/issue490.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ B: A & {
}
-- out/eval --
Errors:
B: field c not allowed:
B: field not allowed: c:
./test.cue:1:10
./test.cue:6:4
./test.cue:7:2
Expand All @@ -26,7 +26,7 @@ Result:
a: (int){ 1 }
b: (int){ 2 }
c: (_|_){
// [eval] B: field c not allowed:
// [eval] B: field not allowed: c:
// ./test.cue:1:10
// ./test.cue:6:4
// ./test.cue:7:2
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/comprehensions/issue293.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ t: #C
t: p: "foo"
-- out/eval --
Errors:
z.x: field f2 not allowed:
z.x: field not allowed: f2:
./in.cue:2:2
./in.cue:5:12
./in.cue:11:4
Expand All @@ -46,7 +46,7 @@ Result:
// [eval]
f1: (int){ 99 }
f2: (_|_){
// [eval] z.x: field f2 not allowed:
// [eval] z.x: field not allowed: f2:
// ./in.cue:2:2
// ./in.cue:5:12
// ./in.cue:11:4
Expand Down
24 changes: 12 additions & 12 deletions cue/testdata/cycle/compbottom2.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ nestedChain: {
}
-- out/eval --
Errors:
mutual.mutualCycleFail.a: cycle: new field bar inserted by if clause that was previously evaluated by another if clause
mutual.oneDirectionalConflictFail.p1.a: cycle: new field bar inserted by if clause that was previously evaluated by another if clause
mutual.oneDirectionalConflictFail.p2.b: cycle: new field foo inserted by if clause that was previously evaluated by another if clause
nestedChain.cycleFail.#E: cycle: new field x inserted by if clause that was previously evaluated by another if clause
sameStruct.cycleFail: cycle: new field raises inserted by if clause that was previously evaluated by another if clause
self.fail.a: cycle: new field b inserted by if clause that was previously evaluated by another if clause
mutual.mutualCycleFail.a: cycle: field inserted by if clause that was previously evaluated by another if clause: bar
mutual.oneDirectionalConflictFail.p1.a: cycle: field inserted by if clause that was previously evaluated by another if clause: bar
mutual.oneDirectionalConflictFail.p2.b: cycle: field inserted by if clause that was previously evaluated by another if clause: foo
nestedChain.cycleFail.#E: cycle: field inserted by if clause that was previously evaluated by another if clause: x
sameStruct.cycleFail: cycle: field inserted by if clause that was previously evaluated by another if clause: raises
self.fail.a: cycle: field inserted by if clause that was previously evaluated by another if clause: b

Result:
(_|_){
Expand All @@ -163,7 +163,7 @@ Result:
fail: (_|_){
// [eval]
a: (_|_){
// [eval] self.fail.a: cycle: new field b inserted by if clause that was previously evaluated by another if clause
// [eval] self.fail.a: cycle: field inserted by if clause that was previously evaluated by another if clause: b
b: (int){ 1 }
}
}
Expand Down Expand Up @@ -193,7 +193,7 @@ Result:
b: (struct){
}
a: (_|_){
// [eval] mutual.mutualCycleFail.a: cycle: new field bar inserted by if clause that was previously evaluated by another if clause
// [eval] mutual.mutualCycleFail.a: cycle: field inserted by if clause that was previously evaluated by another if clause: bar
bar: (string){ "" }
}
}
Expand All @@ -210,7 +210,7 @@ Result:
p1: (_|_){
// [eval]
a: (_|_){
// [eval] mutual.oneDirectionalConflictFail.p1.a: cycle: new field bar inserted by if clause that was previously evaluated by another if clause
// [eval] mutual.oneDirectionalConflictFail.p1.a: cycle: field inserted by if clause that was previously evaluated by another if clause: bar
bar: (string){ "" }
}
b: (struct){
Expand All @@ -222,7 +222,7 @@ Result:
a: (struct){
}
b: (_|_){
// [eval] mutual.oneDirectionalConflictFail.p2.b: cycle: new field foo inserted by if clause that was previously evaluated by another if clause
// [eval] mutual.oneDirectionalConflictFail.p2.b: cycle: field inserted by if clause that was previously evaluated by another if clause: foo
foo: (string){ "" }
}
}
Expand All @@ -247,7 +247,7 @@ Result:
}
}
cycleFail: (_|_){
// [eval] sameStruct.cycleFail: cycle: new field raises inserted by if clause that was previously evaluated by another if clause
// [eval] sameStruct.cycleFail: cycle: field inserted by if clause that was previously evaluated by another if clause: raises
ret: (struct){
a: (int){ 1 }
}
Expand All @@ -268,7 +268,7 @@ Result:
cycleFail: (_|_){
// [eval]
#E: (_|_){
// [eval] nestedChain.cycleFail.#E: cycle: new field x inserted by if clause that was previously evaluated by another if clause
// [eval] nestedChain.cycleFail.#E: cycle: field inserted by if clause that was previously evaluated by another if clause: x
x: (bool){ true }
}
}
Expand Down
50 changes: 25 additions & 25 deletions cue/testdata/cycle/compbottomnofinal.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -359,18 +359,18 @@ large: {
}
-- out/eval --
Errors:
large.p1.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
large.p2.#Y: cycle: field userinfo was added after an if clause evaluated it
large.p2.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
large.p3.#Y: cycle: field userinfo was added after an if clause evaluated it
large.p3.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
large.p4.#Y: cycle: field userinfo was added after an if clause evaluated it
medium.p1.#Y: cycle: field port was added after an if clause evaluated it
medium.p2.#Y: cycle: field port was added after an if clause evaluated it
medium.p3.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
medium.p4.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
minimal.b: cycle: new field port inserted by if clause that was previously evaluated by another if clause
small.p1.#Y: cycle: field port was added after an if clause evaluated it
large.p1.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
large.p2.#Y: cycle: field was added after an if clause evaluated it: userinfo
large.p2.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
large.p3.#Y: cycle: field was added after an if clause evaluated it: userinfo
large.p3.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
large.p4.#Y: cycle: field was added after an if clause evaluated it: userinfo
medium.p1.#Y: cycle: field was added after an if clause evaluated it: port
medium.p2.#Y: cycle: field was added after an if clause evaluated it: port
medium.p3.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
medium.p4.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
minimal.b: cycle: field inserted by if clause that was previously evaluated by another if clause: port
small.p1.#Y: cycle: field was added after an if clause evaluated it: port
error in call to strconv.Atoi: strconv.Atoi: parsing "": invalid syntax:
./in.cue:104:23
error in call to strconv.Atoi: strconv.Atoi: parsing "": invalid syntax:
Expand All @@ -390,7 +390,7 @@ Result:
a: (struct){
}
b: (_|_){
// [eval] minimal.b: cycle: new field port inserted by if clause that was previously evaluated by another if clause
// [eval] minimal.b: cycle: field inserted by if clause that was previously evaluated by another if clause: port
port: (string){ "" }
}
}
Expand All @@ -400,7 +400,7 @@ Result:
p1: (_|_){
// [eval]
#Y: (_|_){
// [eval] small.p1.#Y: cycle: field port was added after an if clause evaluated it
// [eval] small.p1.#Y: cycle: field was added after an if clause evaluated it: port
port: (string){ "" }
}
#X: (#struct){
Expand All @@ -424,7 +424,7 @@ Result:
p1: (_|_){
// [eval]
#Y: (_|_){
// [eval] medium.p1.#Y: cycle: field port was added after an if clause evaluated it
// [eval] medium.p1.#Y: cycle: field was added after an if clause evaluated it: port
port: (string){ "" }
}
Y: (struct){
Expand All @@ -436,7 +436,7 @@ Result:
p2: (_|_){
// [eval]
#Y: (_|_){
// [eval] medium.p2.#Y: cycle: field port was added after an if clause evaluated it
// [eval] medium.p2.#Y: cycle: field was added after an if clause evaluated it: port
port: (string){ "" }
}
#X: (#struct){
Expand All @@ -448,7 +448,7 @@ Result:
p3: (_|_){
// [eval]
Y: (_|_){
// [eval] medium.p3.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
// [eval] medium.p3.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
port: (_|_){
// [eval] error in call to strconv.Atoi: strconv.Atoi: parsing "": invalid syntax:
// ./in.cue:104:23
Expand All @@ -464,7 +464,7 @@ Result:
p4: (_|_){
// [eval]
Y: (_|_){
// [eval] medium.p4.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
// [eval] medium.p4.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
port: (_|_){
// [eval] error in call to strconv.Atoi: strconv.Atoi: parsing "": invalid syntax:
// ./in.cue:126:23
Expand Down Expand Up @@ -508,7 +508,7 @@ Result:
p1: (_|_){
// [eval]
Y: (_|_){
// [eval] large.p1.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
// [eval] large.p1.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
userinfo: (string){ "user" }
host: (string){ "example.com" }
port: (_|_){
Expand All @@ -532,7 +532,7 @@ Result:
// [eval]
X: (string){ "user@example.com" }
Y: (_|_){
// [eval] large.p2.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
// [eval] large.p2.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
userinfo: (string){ "user" }
host: (string){ "example.com" }
port: (_|_){
Expand All @@ -546,7 +546,7 @@ Result:
port: (string){ "" }
}
#Y: (_|_){
// [eval] large.p2.#Y: cycle: field userinfo was added after an if clause evaluated it
// [eval] large.p2.#Y: cycle: field was added after an if clause evaluated it: userinfo
host: (string){ "example.com" }
port: (string){ "" }
userinfo: (string){ "user" }
Expand All @@ -561,7 +561,7 @@ Result:
port: (string){ "" }
}
Y: (_|_){
// [eval] large.p3.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
// [eval] large.p3.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
userinfo: (string){ "user" }
host: (string){ "example.com" }
port: (_|_){
Expand All @@ -570,7 +570,7 @@ Result:
}
}
#Y: (_|_){
// [eval] large.p3.#Y: cycle: field userinfo was added after an if clause evaluated it
// [eval] large.p3.#Y: cycle: field was added after an if clause evaluated it: userinfo
host: (string){ "example.com" }
port: (string){ "" }
userinfo: (string){ "user" }
Expand All @@ -585,7 +585,7 @@ Result:
port: (string){ "" }
}
#Y: (_|_){
// [eval] large.p4.#Y: cycle: field userinfo was added after an if clause evaluated it
// [eval] large.p4.#Y: cycle: field was added after an if clause evaluated it: userinfo
host: (string){ "example.com" }
port: (string){ "" }
userinfo: (string){ "user" }
Expand All @@ -594,7 +594,7 @@ Result:
// [eval]
userinfo: (string){ "user" }
host: (_|_){
// [eval] large.p4.#Y: cycle: field userinfo was added after an if clause evaluated it
// [eval] large.p4.#Y: cycle: field was added after an if clause evaluated it: userinfo
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions cue/testdata/definitions/026_combined_definitions.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ d1: #D1 & {
}
-- out/eval --
Errors:
#D4.env: field b not allowed:
#D4.env: field not allowed: b:
./in.cue:26:7
./in.cue:27:7
./in.cue:30:6
d1.env: field c not allowed:
d1.env: field not allowed: c:
./in.cue:3:7
./in.cue:4:7
./in.cue:9:5
Expand All @@ -148,7 +148,7 @@ Result:
a: (string){ "A" }
b: (string){ "B" }
c: (_|_){
// [eval] d1.env: field c not allowed:
// [eval] d1.env: field not allowed: c:
// ./in.cue:3:7
// ./in.cue:4:7
// ./in.cue:9:5
Expand Down Expand Up @@ -176,7 +176,7 @@ Result:
// [eval]
a: (int){ int }
b: (_|_){
// [eval] #D4.env: field b not allowed:
// [eval] #D4.env: field not allowed: b:
// ./in.cue:26:7
// ./in.cue:27:7
// ./in.cue:30:6
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/definitions/032_definitions_with_embedding.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
}
-- out/eval --
Errors:
#e1.a: field d not allowed:
#e1.a: field not allowed: d:
./in.cue:2:5
./in.cue:6:2
./in.cue:7:5
Expand Down Expand Up @@ -110,7 +110,7 @@ Result:
b: (int){ int }
c: (int){ int }
d: (_|_){
// [eval] #e1.a: field d not allowed:
// [eval] #e1.a: field not allowed: d:
// ./in.cue:2:5
// ./in.cue:6:2
// ./in.cue:7:5
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/definitions/033_Issue_#153.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Junk: {
}
-- out/eval --
Errors:
listOfCloseds.0: field b not allowed:
listOfCloseds.0: field not allowed: b:
./in.cue:2:21
./in.cue:5:10
./in.cue:13:1
Expand All @@ -79,7 +79,7 @@ Result:
// [eval]
a: (int){ |(*(int){ 0 }, (int){ int }) }
b: (_|_){
// [eval] listOfCloseds.0: field b not allowed:
// [eval] listOfCloseds.0: field not allowed: b:
// ./in.cue:2:21
// ./in.cue:5:10
// ./in.cue:13:1
Expand Down

0 comments on commit 3fdad16

Please sign in to comment.