Skip to content

Commit 3fdad16

Browse files
committed
cue: move field name to end of error message
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 <[email protected]> Reviewed-by: Paul Jolly <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]>
1 parent a31dd01 commit 3fdad16

33 files changed

+135
-136
lines changed

cmd/cue/cmd/testdata/script/vet_embed.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ a: 1
3131
e: 2
3232

3333
-- expect-foo --
34-
field c not allowed:
34+
field not allowed: c:
3535
./foo.yaml:2:2
3636
./schema.cue:1:1
3737
./schema.cue:3:7
3838
./schema.cue:7:1
3939
-- expect-stream --
40-
field d not allowed:
40+
field not allowed: d:
4141
./schema.cue:1:1
4242
./schema.cue:3:7
4343
./schema.cue:7:1
4444
./stream.yaml:2:2
4545
-- expect-stream --
46-
field d not allowed:
46+
field not allowed: d:
4747
./schema.cue:1:1
4848
./schema.cue:3:7
4949
./schema.cue:7:1

cmd/cue/cmd/testdata/script/vet_expr.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmp stderr expect-stderr
33

44
-- expect-stderr --
55
translations.hello.lang: incomplete value string
6-
field skip not allowed:
6+
field not allowed: skip:
77
./data.yaml:20:1
88
./vet.cue:1:1
99
./vet.cue:1:8

cue/testdata/builtins/closed.txtar

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ withSubfields: {
4444

4545
-- out/eval --
4646
Errors:
47-
b: field x not allowed:
47+
b: field not allowed: x:
4848
./in.cue:1:10
4949
./in.cue:5:4
5050
./in.cue:5:10
@@ -63,7 +63,7 @@ Result:
6363
b: (int){ int }
6464
}
6565
x: (_|_){
66-
// [eval] b: field x not allowed:
66+
// [eval] b: field not allowed: x:
6767
// ./in.cue:1:10
6868
// ./in.cue:5:4
6969
// ./in.cue:5:10

cue/testdata/builtins/issue490.txtar

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ B: A & {
99
}
1010
-- out/eval --
1111
Errors:
12-
B: field c not allowed:
12+
B: field not allowed: c:
1313
./test.cue:1:10
1414
./test.cue:6:4
1515
./test.cue:7:2
@@ -26,7 +26,7 @@ Result:
2626
a: (int){ 1 }
2727
b: (int){ 2 }
2828
c: (_|_){
29-
// [eval] B: field c not allowed:
29+
// [eval] B: field not allowed: c:
3030
// ./test.cue:1:10
3131
// ./test.cue:6:4
3232
// ./test.cue:7:2

cue/testdata/comprehensions/issue293.txtar

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ t: #C
2626
t: p: "foo"
2727
-- out/eval --
2828
Errors:
29-
z.x: field f2 not allowed:
29+
z.x: field not allowed: f2:
3030
./in.cue:2:2
3131
./in.cue:5:12
3232
./in.cue:11:4
@@ -46,7 +46,7 @@ Result:
4646
// [eval]
4747
f1: (int){ 99 }
4848
f2: (_|_){
49-
// [eval] z.x: field f2 not allowed:
49+
// [eval] z.x: field not allowed: f2:
5050
// ./in.cue:2:2
5151
// ./in.cue:5:12
5252
// ./in.cue:11:4

cue/testdata/cycle/compbottom2.txtar

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ nestedChain: {
148148
}
149149
-- out/eval --
150150
Errors:
151-
mutual.mutualCycleFail.a: cycle: new field bar inserted by if clause that was previously evaluated by another if clause
152-
mutual.oneDirectionalConflictFail.p1.a: cycle: new field bar inserted by if clause that was previously evaluated by another if clause
153-
mutual.oneDirectionalConflictFail.p2.b: cycle: new field foo inserted by if clause that was previously evaluated by another if clause
154-
nestedChain.cycleFail.#E: cycle: new field x inserted by if clause that was previously evaluated by another if clause
155-
sameStruct.cycleFail: cycle: new field raises inserted by if clause that was previously evaluated by another if clause
156-
self.fail.a: cycle: new field b inserted by if clause that was previously evaluated by another if clause
151+
mutual.mutualCycleFail.a: cycle: field inserted by if clause that was previously evaluated by another if clause: bar
152+
mutual.oneDirectionalConflictFail.p1.a: cycle: field inserted by if clause that was previously evaluated by another if clause: bar
153+
mutual.oneDirectionalConflictFail.p2.b: cycle: field inserted by if clause that was previously evaluated by another if clause: foo
154+
nestedChain.cycleFail.#E: cycle: field inserted by if clause that was previously evaluated by another if clause: x
155+
sameStruct.cycleFail: cycle: field inserted by if clause that was previously evaluated by another if clause: raises
156+
self.fail.a: cycle: field inserted by if clause that was previously evaluated by another if clause: b
157157

158158
Result:
159159
(_|_){
@@ -163,7 +163,7 @@ Result:
163163
fail: (_|_){
164164
// [eval]
165165
a: (_|_){
166-
// [eval] self.fail.a: cycle: new field b inserted by if clause that was previously evaluated by another if clause
166+
// [eval] self.fail.a: cycle: field inserted by if clause that was previously evaluated by another if clause: b
167167
b: (int){ 1 }
168168
}
169169
}
@@ -193,7 +193,7 @@ Result:
193193
b: (struct){
194194
}
195195
a: (_|_){
196-
// [eval] mutual.mutualCycleFail.a: cycle: new field bar inserted by if clause that was previously evaluated by another if clause
196+
// [eval] mutual.mutualCycleFail.a: cycle: field inserted by if clause that was previously evaluated by another if clause: bar
197197
bar: (string){ "" }
198198
}
199199
}
@@ -210,7 +210,7 @@ Result:
210210
p1: (_|_){
211211
// [eval]
212212
a: (_|_){
213-
// [eval] mutual.oneDirectionalConflictFail.p1.a: cycle: new field bar inserted by if clause that was previously evaluated by another if clause
213+
// [eval] mutual.oneDirectionalConflictFail.p1.a: cycle: field inserted by if clause that was previously evaluated by another if clause: bar
214214
bar: (string){ "" }
215215
}
216216
b: (struct){
@@ -222,7 +222,7 @@ Result:
222222
a: (struct){
223223
}
224224
b: (_|_){
225-
// [eval] mutual.oneDirectionalConflictFail.p2.b: cycle: new field foo inserted by if clause that was previously evaluated by another if clause
225+
// [eval] mutual.oneDirectionalConflictFail.p2.b: cycle: field inserted by if clause that was previously evaluated by another if clause: foo
226226
foo: (string){ "" }
227227
}
228228
}
@@ -247,7 +247,7 @@ Result:
247247
}
248248
}
249249
cycleFail: (_|_){
250-
// [eval] sameStruct.cycleFail: cycle: new field raises inserted by if clause that was previously evaluated by another if clause
250+
// [eval] sameStruct.cycleFail: cycle: field inserted by if clause that was previously evaluated by another if clause: raises
251251
ret: (struct){
252252
a: (int){ 1 }
253253
}
@@ -268,7 +268,7 @@ Result:
268268
cycleFail: (_|_){
269269
// [eval]
270270
#E: (_|_){
271-
// [eval] nestedChain.cycleFail.#E: cycle: new field x inserted by if clause that was previously evaluated by another if clause
271+
// [eval] nestedChain.cycleFail.#E: cycle: field inserted by if clause that was previously evaluated by another if clause: x
272272
x: (bool){ true }
273273
}
274274
}

cue/testdata/cycle/compbottomnofinal.txtar

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -359,18 +359,18 @@ large: {
359359
}
360360
-- out/eval --
361361
Errors:
362-
large.p1.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
363-
large.p2.#Y: cycle: field userinfo was added after an if clause evaluated it
364-
large.p2.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
365-
large.p3.#Y: cycle: field userinfo was added after an if clause evaluated it
366-
large.p3.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
367-
large.p4.#Y: cycle: field userinfo was added after an if clause evaluated it
368-
medium.p1.#Y: cycle: field port was added after an if clause evaluated it
369-
medium.p2.#Y: cycle: field port was added after an if clause evaluated it
370-
medium.p3.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
371-
medium.p4.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
372-
minimal.b: cycle: new field port inserted by if clause that was previously evaluated by another if clause
373-
small.p1.#Y: cycle: field port was added after an if clause evaluated it
362+
large.p1.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
363+
large.p2.#Y: cycle: field was added after an if clause evaluated it: userinfo
364+
large.p2.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
365+
large.p3.#Y: cycle: field was added after an if clause evaluated it: userinfo
366+
large.p3.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
367+
large.p4.#Y: cycle: field was added after an if clause evaluated it: userinfo
368+
medium.p1.#Y: cycle: field was added after an if clause evaluated it: port
369+
medium.p2.#Y: cycle: field was added after an if clause evaluated it: port
370+
medium.p3.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
371+
medium.p4.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
372+
minimal.b: cycle: field inserted by if clause that was previously evaluated by another if clause: port
373+
small.p1.#Y: cycle: field was added after an if clause evaluated it: port
374374
error in call to strconv.Atoi: strconv.Atoi: parsing "": invalid syntax:
375375
./in.cue:104:23
376376
error in call to strconv.Atoi: strconv.Atoi: parsing "": invalid syntax:
@@ -390,7 +390,7 @@ Result:
390390
a: (struct){
391391
}
392392
b: (_|_){
393-
// [eval] minimal.b: cycle: new field port inserted by if clause that was previously evaluated by another if clause
393+
// [eval] minimal.b: cycle: field inserted by if clause that was previously evaluated by another if clause: port
394394
port: (string){ "" }
395395
}
396396
}
@@ -400,7 +400,7 @@ Result:
400400
p1: (_|_){
401401
// [eval]
402402
#Y: (_|_){
403-
// [eval] small.p1.#Y: cycle: field port was added after an if clause evaluated it
403+
// [eval] small.p1.#Y: cycle: field was added after an if clause evaluated it: port
404404
port: (string){ "" }
405405
}
406406
#X: (#struct){
@@ -424,7 +424,7 @@ Result:
424424
p1: (_|_){
425425
// [eval]
426426
#Y: (_|_){
427-
// [eval] medium.p1.#Y: cycle: field port was added after an if clause evaluated it
427+
// [eval] medium.p1.#Y: cycle: field was added after an if clause evaluated it: port
428428
port: (string){ "" }
429429
}
430430
Y: (struct){
@@ -436,7 +436,7 @@ Result:
436436
p2: (_|_){
437437
// [eval]
438438
#Y: (_|_){
439-
// [eval] medium.p2.#Y: cycle: field port was added after an if clause evaluated it
439+
// [eval] medium.p2.#Y: cycle: field was added after an if clause evaluated it: port
440440
port: (string){ "" }
441441
}
442442
#X: (#struct){
@@ -448,7 +448,7 @@ Result:
448448
p3: (_|_){
449449
// [eval]
450450
Y: (_|_){
451-
// [eval] medium.p3.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
451+
// [eval] medium.p3.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
452452
port: (_|_){
453453
// [eval] error in call to strconv.Atoi: strconv.Atoi: parsing "": invalid syntax:
454454
// ./in.cue:104:23
@@ -464,7 +464,7 @@ Result:
464464
p4: (_|_){
465465
// [eval]
466466
Y: (_|_){
467-
// [eval] medium.p4.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
467+
// [eval] medium.p4.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
468468
port: (_|_){
469469
// [eval] error in call to strconv.Atoi: strconv.Atoi: parsing "": invalid syntax:
470470
// ./in.cue:126:23
@@ -508,7 +508,7 @@ Result:
508508
p1: (_|_){
509509
// [eval]
510510
Y: (_|_){
511-
// [eval] large.p1.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
511+
// [eval] large.p1.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
512512
userinfo: (string){ "user" }
513513
host: (string){ "example.com" }
514514
port: (_|_){
@@ -532,7 +532,7 @@ Result:
532532
// [eval]
533533
X: (string){ "[email protected]" }
534534
Y: (_|_){
535-
// [eval] large.p2.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
535+
// [eval] large.p2.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
536536
userinfo: (string){ "user" }
537537
host: (string){ "example.com" }
538538
port: (_|_){
@@ -546,7 +546,7 @@ Result:
546546
port: (string){ "" }
547547
}
548548
#Y: (_|_){
549-
// [eval] large.p2.#Y: cycle: field userinfo was added after an if clause evaluated it
549+
// [eval] large.p2.#Y: cycle: field was added after an if clause evaluated it: userinfo
550550
host: (string){ "example.com" }
551551
port: (string){ "" }
552552
userinfo: (string){ "user" }
@@ -561,7 +561,7 @@ Result:
561561
port: (string){ "" }
562562
}
563563
Y: (_|_){
564-
// [eval] large.p3.Y: cycle: new field port inserted by if clause that was previously evaluated by another if clause
564+
// [eval] large.p3.Y: cycle: field inserted by if clause that was previously evaluated by another if clause: port
565565
userinfo: (string){ "user" }
566566
host: (string){ "example.com" }
567567
port: (_|_){
@@ -570,7 +570,7 @@ Result:
570570
}
571571
}
572572
#Y: (_|_){
573-
// [eval] large.p3.#Y: cycle: field userinfo was added after an if clause evaluated it
573+
// [eval] large.p3.#Y: cycle: field was added after an if clause evaluated it: userinfo
574574
host: (string){ "example.com" }
575575
port: (string){ "" }
576576
userinfo: (string){ "user" }
@@ -585,7 +585,7 @@ Result:
585585
port: (string){ "" }
586586
}
587587
#Y: (_|_){
588-
// [eval] large.p4.#Y: cycle: field userinfo was added after an if clause evaluated it
588+
// [eval] large.p4.#Y: cycle: field was added after an if clause evaluated it: userinfo
589589
host: (string){ "example.com" }
590590
port: (string){ "" }
591591
userinfo: (string){ "user" }
@@ -594,7 +594,7 @@ Result:
594594
// [eval]
595595
userinfo: (string){ "user" }
596596
host: (_|_){
597-
// [eval] large.p4.#Y: cycle: field userinfo was added after an if clause evaluated it
597+
// [eval] large.p4.#Y: cycle: field was added after an if clause evaluated it: userinfo
598598
}
599599
}
600600
}

cue/testdata/definitions/026_combined_definitions.txtar

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ d1: #D1 & {
118118
}
119119
-- out/eval --
120120
Errors:
121-
#D4.env: field b not allowed:
121+
#D4.env: field not allowed: b:
122122
./in.cue:26:7
123123
./in.cue:27:7
124124
./in.cue:30:6
125-
d1.env: field c not allowed:
125+
d1.env: field not allowed: c:
126126
./in.cue:3:7
127127
./in.cue:4:7
128128
./in.cue:9:5
@@ -148,7 +148,7 @@ Result:
148148
a: (string){ "A" }
149149
b: (string){ "B" }
150150
c: (_|_){
151-
// [eval] d1.env: field c not allowed:
151+
// [eval] d1.env: field not allowed: c:
152152
// ./in.cue:3:7
153153
// ./in.cue:4:7
154154
// ./in.cue:9:5
@@ -176,7 +176,7 @@ Result:
176176
// [eval]
177177
a: (int){ int }
178178
b: (_|_){
179-
// [eval] #D4.env: field b not allowed:
179+
// [eval] #D4.env: field not allowed: b:
180180
// ./in.cue:26:7
181181
// ./in.cue:27:7
182182
// ./in.cue:30:6

cue/testdata/definitions/032_definitions_with_embedding.txtar

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
}
8282
-- out/eval --
8383
Errors:
84-
#e1.a: field d not allowed:
84+
#e1.a: field not allowed: d:
8585
./in.cue:2:5
8686
./in.cue:6:2
8787
./in.cue:7:5
@@ -110,7 +110,7 @@ Result:
110110
b: (int){ int }
111111
c: (int){ int }
112112
d: (_|_){
113-
// [eval] #e1.a: field d not allowed:
113+
// [eval] #e1.a: field not allowed: d:
114114
// ./in.cue:2:5
115115
// ./in.cue:6:2
116116
// ./in.cue:7:5

cue/testdata/definitions/033_Issue_#153.txtar

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Junk: {
6262
}
6363
-- out/eval --
6464
Errors:
65-
listOfCloseds.0: field b not allowed:
65+
listOfCloseds.0: field not allowed: b:
6666
./in.cue:2:21
6767
./in.cue:5:10
6868
./in.cue:13:1
@@ -79,7 +79,7 @@ Result:
7979
// [eval]
8080
a: (int){ |(*(int){ 0 }, (int){ int }) }
8181
b: (_|_){
82-
// [eval] listOfCloseds.0: field b not allowed:
82+
// [eval] listOfCloseds.0: field not allowed: b:
8383
// ./in.cue:2:21
8484
// ./in.cue:5:10
8585
// ./in.cue:13:1

0 commit comments

Comments
 (0)