Skip to content

Commit b67dc4d

Browse files
committed
interal/core/adt: improve error locations
link parents for literal structs and lists This is not so relevant now, but will be with the comprehension rework. Signed-off-by: Marcel van Lohuizen <mpvl@golang.org> Change-Id: I4fce69f765a37990dfb7a0f48f150e6bc3c53937 Signed-off-by: Marcel van Lohuizen <mpvl@golang.org> Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/529865 Reviewed-by: Paul Jolly <paul@myitcv.io>
1 parent 4136481 commit b67dc4d

File tree

6 files changed

+114
-71
lines changed

6 files changed

+114
-71
lines changed

cue/testdata/builtins/all.txtar

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Errors:
2323
fatalArg.x: invalid operands "eee" and 'eee' to '+' (type string and bytes):
2424
./in.cue:3:12
2525
./in.cue:3:20
26-
0.a: undefined field: c:
26+
fatalChild.0.a: undefined field: c:
2727
./in.cue:9:20
2828

2929
Result:
@@ -42,7 +42,7 @@ Result:
4242
#b: (#struct){
4343
}
4444
x: (_|_){
45-
// [eval] 0.a: undefined field: c:
45+
// [eval] fatalChild.0.a: undefined field: c:
4646
// ./in.cue:9:20
4747
}
4848
}

cue/testdata/builtins/incomplete.txtar

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ Result:
192192
// ./in.cue:50:23
193193
}
194194
max: (_|_){
195-
// [incomplete] 0: operand param of '+' not concrete (was int):
195+
// [incomplete] incompleteArgDecimalList.#a.0: operand param of '+' not concrete (was int):
196196
// ./in.cue:50:23
197197
}
198198
}
@@ -211,7 +211,7 @@ Result:
211211
// ./in.cue:58:9
212212
}
213213
joined: (_|_){
214-
// [incomplete] 0: non-concrete value string in operand to +:
214+
// [incomplete] incompleteArgStringList.#a.0: non-concrete value string in operand to +:
215215
// ./in.cue:59:22
216216
// ./in.cue:58:9
217217
}

cue/testdata/cycle/structural.txtar

Lines changed: 64 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ d2: {
275275
}
276276

277277
d3: {
278-
// TODO(errors): correct position reporting in structural cycle.
279278
config: {
280279
a: b: c: indirect
281280
indirect: [a.b, null][i]
@@ -462,72 +461,72 @@ e1.b.c: structural cycle
462461
e2.a.c: structural cycle
463462
e2.b.c: structural cycle
464463
e3.a: conflicting values [a] and {c:a} (mismatched types list and struct):
464+
./in.cue:304:8
465465
./in.cue:305:8
466-
./in.cue:306:8
467466
e3.a.0: conflicting values [a] and {c:a} (mismatched types list and struct):
467+
./in.cue:304:8
468+
./in.cue:304:9
468469
./in.cue:305:8
469-
./in.cue:305:9
470-
./in.cue:306:8
471470
e3.a.0: structural cycle
472471
e3.a.c: conflicting values [a] and {c:a} (mismatched types list and struct):
472+
./in.cue:304:8
473473
./in.cue:305:8
474-
./in.cue:306:8
475-
./in.cue:306:11
474+
./in.cue:305:11
476475
e3.a.c: structural cycle
477476
e3.b: conflicting values [b] and {c:b} (mismatched types list and struct):
477+
./in.cue:307:8
478478
./in.cue:308:8
479-
./in.cue:309:8
480479
e3.b.0: conflicting values [b] and {c:b} (mismatched types list and struct):
480+
./in.cue:307:8
481+
./in.cue:307:9
481482
./in.cue:308:8
482-
./in.cue:308:9
483-
./in.cue:309:8
484483
e3.b.0: structural cycle
485484
e3.b.c: conflicting values [b] and {c:b} (mismatched types list and struct):
485+
./in.cue:307:8
486486
./in.cue:308:8
487-
./in.cue:309:8
488-
./in.cue:309:11
487+
./in.cue:308:11
489488
e3.b.c: structural cycle
490489
e4.a.0: 4 errors in empty disjunction:
491490
e4.a.0: conflicting values [{c:1}] and {} (mismatched types list and struct):
492-
./in.cue:313:13
493-
./in.cue:314:9
491+
./in.cue:312:13
492+
./in.cue:313:9
494493
e4.a.0.0: 2 errors in empty disjunction:
495494
e4.a.0.0: conflicting values [[{c:1}]] and {c:1} (mismatched types list and struct):
496-
./in.cue:314:8
497-
./in.cue:314:10
495+
./in.cue:313:8
496+
./in.cue:313:10
498497
e4.a.0.0: conflicting values [{c:1}] and {} (mismatched types list and struct):
498+
./in.cue:312:9
499+
./in.cue:312:13
499500
./in.cue:313:9
500-
./in.cue:313:13
501-
./in.cue:314:9
502501
e4.b.0: 4 errors in empty disjunction:
503502
e4.b.0: conflicting values [{c:1}] and {} (mismatched types list and struct):
504-
./in.cue:316:9
505-
./in.cue:317:13
503+
./in.cue:315:9
504+
./in.cue:316:13
506505
e4.b.0.0: 2 errors in empty disjunction:
507506
e4.b.0.0: conflicting values [(b|{})] and {c:1} (mismatched types list and struct):
508-
./in.cue:316:10
509-
./in.cue:317:8
507+
./in.cue:315:10
508+
./in.cue:316:8
510509
e4.b.0.0: conflicting values [{c:1}] and {} (mismatched types list and struct):
510+
./in.cue:315:9
511511
./in.cue:316:9
512-
./in.cue:317:9
513-
./in.cue:317:13
512+
./in.cue:316:13
514513
nestedList.v1e.y.0: 4 errors in empty disjunction:
515514
nestedList.v1e.y.0: conflicting values int and [[2],1] (mismatched types int and list):
515+
./in.cue:332:17
516516
./in.cue:333:17
517-
./in.cue:334:17
518517
nestedList.v1e.y.0.0: 2 errors in empty disjunction:
519518
nestedList.v1e.y.0.0: conflicting values int and [2] (mismatched types int and list):
520-
./in.cue:333:17
521-
./in.cue:334:18
519+
./in.cue:332:17
520+
./in.cue:333:18
522521
nestedList.v1e.y.0.0: incompatible list lengths (1 and 2)
523522
nestedList.v2e.y.0: 4 errors in empty disjunction:
524523
nestedList.v2e.y.0: conflicting values int and [[2],1] (mismatched types int and list):
524+
./in.cue:337:17
525525
./in.cue:338:17
526-
./in.cue:339:17
527526
nestedList.v2e.y.0.0: 2 errors in empty disjunction:
528527
nestedList.v2e.y.0.0: conflicting values int and [2] (mismatched types int and list):
529-
./in.cue:338:18
530-
./in.cue:339:17
528+
./in.cue:337:18
529+
./in.cue:338:17
531530
nestedList.v2e.y.0.0: incompatible list lengths (1 and 2)
532531
p2.#T.a.b.link: structural cycle
533532
p3.#U.#T.a.b.link: structural cycle
@@ -537,8 +536,8 @@ z1.z.f.h.h: structural cycle
537536
z1.z.g.h: structural cycle
538537
cycle error:
539538
./in.cue:141:10
540-
0: structural cycle:
541-
./in.cue:280:19
539+
d3.config.0: structural cycle:
540+
./in.cue:279:19
542541

543542
Result:
544543
(_|_){
@@ -1148,20 +1147,20 @@ Result:
11481147
b: (_|_){
11491148
// [structural cycle]
11501149
c: (_|_){
1151-
// [structural cycle] 0: structural cycle:
1152-
// ./in.cue:280:19
1150+
// [structural cycle] d3.config.0: structural cycle:
1151+
// ./in.cue:279:19
11531152
}
11541153
}
11551154
}
11561155
indirect: (_|_){
1157-
// [structural cycle] 0: structural cycle:
1158-
// ./in.cue:280:19
1156+
// [structural cycle] d3.config.0: structural cycle:
1157+
// ./in.cue:279:19
11591158
}
11601159
i: (int){ |(*(int){ 1 }, (int){ int }) }
11611160
}
11621161
x: (_|_){
1163-
// [structural cycle] 0: structural cycle:
1164-
// ./in.cue:280:19
1162+
// [structural cycle] d3.config.0: structural cycle:
1163+
// ./in.cue:279:19
11651164
i: (int){ 0 }
11661165
}
11671166
}
@@ -1199,39 +1198,39 @@ Result:
11991198
// [eval]
12001199
a: (_|_){
12011200
// [eval] e3.a: conflicting values [a] and {c:a} (mismatched types list and struct):
1201+
// ./in.cue:304:8
12021202
// ./in.cue:305:8
1203-
// ./in.cue:306:8
12041203
c: (_|_){
12051204
// [eval] e3.a.c: conflicting values [a] and {c:a} (mismatched types list and struct):
1205+
// ./in.cue:304:8
12061206
// ./in.cue:305:8
1207-
// ./in.cue:306:8
1208-
// ./in.cue:306:11
1207+
// ./in.cue:305:11
12091208
// e3.a.c: structural cycle
12101209
}
12111210
0: (_|_){
12121211
// [eval] e3.a.0: conflicting values [a] and {c:a} (mismatched types list and struct):
1212+
// ./in.cue:304:8
1213+
// ./in.cue:304:9
12131214
// ./in.cue:305:8
1214-
// ./in.cue:305:9
1215-
// ./in.cue:306:8
12161215
// e3.a.0: structural cycle
12171216
}
12181217
}
12191218
b: (_|_){
12201219
// [eval] e3.b: conflicting values [b] and {c:b} (mismatched types list and struct):
1220+
// ./in.cue:307:8
12211221
// ./in.cue:308:8
1222-
// ./in.cue:309:8
12231222
c: (_|_){
12241223
// [eval] e3.b.c: conflicting values [b] and {c:b} (mismatched types list and struct):
1224+
// ./in.cue:307:8
12251225
// ./in.cue:308:8
1226-
// ./in.cue:309:8
1227-
// ./in.cue:309:11
1226+
// ./in.cue:308:11
12281227
// e3.b.c: structural cycle
12291228
}
12301229
0: (_|_){
12311230
// [eval] e3.b.0: conflicting values [b] and {c:b} (mismatched types list and struct):
1231+
// ./in.cue:307:8
1232+
// ./in.cue:307:9
12321233
// ./in.cue:308:8
1233-
// ./in.cue:308:9
1234-
// ./in.cue:309:8
12351234
// e3.b.0: structural cycle
12361235
}
12371236
}
@@ -1243,16 +1242,16 @@ Result:
12431242
0: (_|_){
12441243
// [eval] e4.a.0: 4 errors in empty disjunction:
12451244
// e4.a.0: conflicting values [{c:1}] and {} (mismatched types list and struct):
1246-
// ./in.cue:313:13
1247-
// ./in.cue:314:9
1245+
// ./in.cue:312:13
1246+
// ./in.cue:313:9
12481247
// e4.a.0.0: 2 errors in empty disjunction:
12491248
// e4.a.0.0: conflicting values [[{c:1}]] and {c:1} (mismatched types list and struct):
1250-
// ./in.cue:314:8
1251-
// ./in.cue:314:10
1249+
// ./in.cue:313:8
1250+
// ./in.cue:313:10
12521251
// e4.a.0.0: conflicting values [{c:1}] and {} (mismatched types list and struct):
1252+
// ./in.cue:312:9
1253+
// ./in.cue:312:13
12531254
// ./in.cue:313:9
1254-
// ./in.cue:313:13
1255-
// ./in.cue:314:9
12561255
0: (struct){
12571256
c: (int){ 1 }
12581257
}
@@ -1263,16 +1262,16 @@ Result:
12631262
0: (_|_){
12641263
// [eval] e4.b.0: 4 errors in empty disjunction:
12651264
// e4.b.0: conflicting values [{c:1}] and {} (mismatched types list and struct):
1266-
// ./in.cue:316:9
1267-
// ./in.cue:317:13
1265+
// ./in.cue:315:9
1266+
// ./in.cue:316:13
12681267
// e4.b.0.0: 2 errors in empty disjunction:
12691268
// e4.b.0.0: conflicting values [(b|{})] and {c:1} (mismatched types list and struct):
1270-
// ./in.cue:316:10
1271-
// ./in.cue:317:8
1269+
// ./in.cue:315:10
1270+
// ./in.cue:316:8
12721271
// e4.b.0.0: conflicting values [{c:1}] and {} (mismatched types list and struct):
1272+
// ./in.cue:315:9
12731273
// ./in.cue:316:9
1274-
// ./in.cue:317:9
1275-
// ./in.cue:317:13
1274+
// ./in.cue:316:13
12761275
0: (struct){
12771276
c: (int){ 1 }
12781277
}
@@ -1300,12 +1299,12 @@ Result:
13001299
0: (_|_){
13011300
// [eval] nestedList.v1e.y.0: 4 errors in empty disjunction:
13021301
// nestedList.v1e.y.0: conflicting values int and [[2],1] (mismatched types int and list):
1302+
// ./in.cue:332:17
13031303
// ./in.cue:333:17
1304-
// ./in.cue:334:17
13051304
// nestedList.v1e.y.0.0: 2 errors in empty disjunction:
13061305
// nestedList.v1e.y.0.0: conflicting values int and [2] (mismatched types int and list):
1307-
// ./in.cue:333:17
1308-
// ./in.cue:334:18
1306+
// ./in.cue:332:17
1307+
// ./in.cue:333:18
13091308
// nestedList.v1e.y.0.0: incompatible list lengths (1 and 2)
13101309
0: (#list){
13111310
0: (int){ 2 }
@@ -1322,12 +1321,12 @@ Result:
13221321
0: (_|_){
13231322
// [eval] nestedList.v2e.y.0: 4 errors in empty disjunction:
13241323
// nestedList.v2e.y.0: conflicting values int and [[2],1] (mismatched types int and list):
1324+
// ./in.cue:337:17
13251325
// ./in.cue:338:17
1326-
// ./in.cue:339:17
13271326
// nestedList.v2e.y.0.0: 2 errors in empty disjunction:
13281327
// nestedList.v2e.y.0.0: conflicting values int and [2] (mismatched types int and list):
1329-
// ./in.cue:338:18
1330-
// ./in.cue:339:17
1328+
// ./in.cue:337:18
1329+
// ./in.cue:338:17
13311330
// nestedList.v2e.y.0.0: incompatible list lengths (1 and 2)
13321331
0: (#list){
13331332
0: (int){ 2 }

cue/testdata/eval/comprehensions.txtar

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
-- in.cue --
2+
import "strings"
3+
24
a: { x: 10, y: 100, z: 50 }
35
b: {
46
for k, v in a if v <= 50 {
@@ -19,6 +21,16 @@ c: {
1921
"\(k)": y
2022
}
2123
}
24+
25+
A: X: run: "dfoo"
26+
27+
if true {
28+
A: X: {
29+
run: string
30+
files: "\(strings.Join([ run ], "\n"))"
31+
}
32+
}
33+
2234
-- out/eval --
2335
(struct){
2436
a: (struct){
@@ -36,6 +48,12 @@ c: {
3648
y: (int){ 110 }
3749
z: (int){ 60 }
3850
}
51+
A: (struct){
52+
X: (struct){
53+
run: (string){ "dfoo" }
54+
files: (string){ "dfoo" }
55+
}
56+
}
3957
}
4058
-- out/compile --
4159
--- in.cue
@@ -63,4 +81,19 @@ c: {
6381
"\(〈2;k〉)": 〈1;y〉
6482
}
6583
}
84+
A: {
85+
X: {
86+
run: "dfoo"
87+
}
88+
}
89+
if true {
90+
A: {
91+
X: {
92+
run: string
93+
files: "\(〈import;strings〉.Join([
94+
〈1;run〉,
95+
], "\n"))"
96+
}
97+
}
98+
}
6699
}

internal/core/adt/closed2.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ func isComplexStruct(ctx *OpContext, v *Vertex) bool {
3232
// TODO: cleanup code and error messages. Reduce duplication in some related
3333
// code.
3434
func verifyArc2(ctx *OpContext, f Feature, v *Vertex, isClosed bool) (found bool, err *Bottom) {
35+
// Don't check computed, temporary vertices.
36+
if v.Label == InvalidLabel {
37+
return true, nil
38+
}
39+
3540
// TODO(perf): collect positions in error.
3641
defer ctx.ReleasePositions(ctx.MarkPositions())
3742

0 commit comments

Comments
 (0)