Skip to content

Commit 0eb7cc5

Browse files
committed
internal/core/eval: add more positions to conflict errors
This should bring conflict errors mostly up to par with v0.2.2. It also adds some context errors for definitions. More refined tracing of references (in acceptor.Canopy) will be able to address Issue #129. Change-Id: Ic359a324c2d3034b4895b06cb7f91c3c546a8a0a Reviewed-on: https://cue-review.googlesource.com/c/cue/+/7302 Reviewed-by: CUE cueckoo <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]>
1 parent 80f0bee commit 0eb7cc5

38 files changed

+604
-155
lines changed

cmd/cue/cmd/testdata/script/cmd_baddisplay.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
cmp stderr cmd_baddisplay.out
44

55
-- cmd_baddisplay.out --
6-
command.baddisplay.display.text: conflicting values 42 and string (mismatched types int and string)
6+
command.baddisplay.display.text: conflicting values 42 and string (mismatched types int and string):
7+
./task_tool.cue:6:9
8+
tool/cli:4:9
79
-- task.cue --
810
package home
911
message: "Hello world!"

cmd/cue/cmd/testdata/script/def_jsonschema.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ unsupported constraint "foo":
6868
age: twenty
6969

7070
-- expect-stderr2 --
71-
age: conflicting values "twenty" and int (mismatched types string and int)
71+
age: conflicting values "twenty" and int (mismatched types string and int):
72+
./data.yaml:1:7
73+
./schema.json:18:7
7274
-- expect-stderr3 --
73-
age: conflicting values "twenty" and int (mismatched types string and int)
75+
age: conflicting values "twenty" and int (mismatched types string and int):
76+
./data.yaml:1:7
77+
./schema.json:18:7
7478
-- cue.mod --

cmd/cue/cmd/testdata/script/eval_errs.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ cmp stdout expect-stdout
44

55
-- expect-stdout --
66
-- expect-stderr --
7-
bar.b: conflicting values 2 and string (mismatched types int and string)
8-
x.q: incompatible values "goodbye" and "hello"
7+
bar.b: conflicting values 2 and string (mismatched types int and string):
8+
./errs.cue:5:21
9+
./errs.cue:6:26
10+
x.q: conflicting values "goodbye" and "hello":
11+
./errs.cue:1:4
12+
./errs.cue:2:4
913
-- errs.cue --
1014
a: "hello"
1115
b: "goodbye"

cmd/cue/cmd/testdata/script/vet_file.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ cmp stderr expect-stderr2
66

77
-- expect-stderr --
88
translations.hello.lang: incomplete value string
9-
translations.hello.lang: conflicting values false and string (mismatched types bool and string)
9+
translations.hello.lang: conflicting values false and string (mismatched types bool and string):
10+
./data.yaml:13:11
11+
./vet.cue:3:31
1012
-- expect-stderr2 --
1113
translations.hello.lang: incomplete value string
12-
translations.hello.lang: conflicting values false and string (mismatched types bool and string)
14+
translations.hello.lang: conflicting values false and string (mismatched types bool and string):
15+
./data.yaml:13:11
16+
./vet.cue:3:31
1317
-- vet.cue --
1418
package foo
1519

cue/testdata/basicrewrite/001_regexp.txtar

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ e3: _|_ // conflicting values !="a" and <5 (mismatched types string and number)
6666
}
6767
-- out/eval --
6868
Errors:
69-
e3: conflicting values !="a" and <5 (mismatched types string and number)
69+
e3: conflicting values !="a" and <5 (mismatched types string and number):
70+
./in.cue:22:5
71+
./in.cue:22:13
7072
b3: invalid value "foo" (out of bound =~"[a-z]{4}"):
7173
./in.cue:10:5
7274
e1: cannot use 1 (type int) as type (string|bytes):
@@ -101,6 +103,8 @@ Result:
101103
// ./in.cue:21:5
102104
}
103105
e3: (_|_){
104-
// [eval] e3: conflicting values !="a" and <5 (mismatched types string and number)
106+
// [eval] e3: conflicting values !="a" and <5 (mismatched types string and number):
107+
// ./in.cue:22:5
108+
// ./in.cue:22:13
105109
}
106110
}

cue/testdata/basicrewrite/004_booleans.txtar

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,18 @@ e: _|_ // conflicting values true and false
2727
}
2828
-- out/eval --
2929
Errors:
30-
e: incompatible values false and true
30+
e: conflicting values false and true:
31+
./in.cue:5:4
32+
./in.cue:6:4
3133

3234
Result:
3335
(_|_){
3436
// [eval]
3537
t: (bool){ true }
3638
f: (bool){ false }
3739
e: (_|_){
38-
// [eval] e: incompatible values false and true
40+
// [eval] e: conflicting values false and true:
41+
// ./in.cue:5:4
42+
// ./in.cue:6:4
3943
}
4044
}

cue/testdata/basicrewrite/005_boolean_arithmetic.txtar

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ f: _|_ // conflicting values true and false
3030
}
3131
-- out/eval --
3232
Errors:
33-
f: incompatible values false and true
33+
f: conflicting values false and true:
34+
./in.cue:6:4
35+
./in.cue:6:11
3436

3537
Result:
3638
(_|_){
@@ -41,6 +43,8 @@ Result:
4143
d: (bool){ true }
4244
e: (bool){ true }
4345
f: (_|_){
44-
// [eval] f: incompatible values false and true
46+
// [eval] f: conflicting values false and true:
47+
// ./in.cue:6:4
48+
// ./in.cue:6:11
4549
}
4650
}

cue/testdata/basicrewrite/006_basic_type.txtar

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ f: true
3434
}
3535
-- out/eval --
3636
Errors:
37-
d: conflicting values int and float (mismatched types int and float)
37+
d: conflicting values int and float (mismatched types int and float):
38+
./in.cue:5:4
39+
./in.cue:5:10
3840

3941
Result:
4042
(_|_){
@@ -43,7 +45,9 @@ Result:
4345
b: (int){ 1 }
4446
c: (float){ 1.0 }
4547
d: (_|_){
46-
// [eval] d: conflicting values int and float (mismatched types int and float)
48+
// [eval] d: conflicting values int and float (mismatched types int and float):
49+
// ./in.cue:5:4
50+
// ./in.cue:5:10
4751
}
4852
e: (string){ "4" }
4953
f: (bool){ true }

cue/testdata/basicrewrite/010_lists.txtar

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,19 @@ e5: [1, 2, 4, _|_, // invalid value 8 (out of bound <=5)
7676
}
7777
-- out/eval --
7878
Errors:
79-
e: conflicting values 4 and [] (mismatched types int and list)
79+
e: conflicting values 4 and [] (mismatched types int and list):
80+
./in.cue:4:8
81+
./in.cue:4:13
8082
e2: invalid list index d (type string):
8183
./in.cue:5:12
8284
e3: invalid negative index -1:
8385
./in.cue:6:8
8486
e4.3: invalid value 8 (out of bound <=5):
8587
./in.cue:7:24
88+
./in.cue:7:41
8689
e5.3: invalid value 8 (out of bound <=5):
8790
./in.cue:8:39
91+
./in.cue:8:18
8892

8993
Result:
9094
(_|_){
@@ -101,7 +105,9 @@ Result:
101105
2: (int){ 3 }
102106
}
103107
e: (_|_){
104-
// [eval] e: conflicting values 4 and [] (mismatched types int and list)
108+
// [eval] e: conflicting values 4 and [] (mismatched types int and list):
109+
// ./in.cue:4:8
110+
// ./in.cue:4:13
105111
}
106112
e2: (_|_){
107113
// [eval] e2: invalid list index d (type string):
@@ -119,6 +125,7 @@ Result:
119125
3: (_|_){
120126
// [eval] e4.3: invalid value 8 (out of bound <=5):
121127
// ./in.cue:7:24
128+
// ./in.cue:7:41
122129
}
123130
}
124131
e5: (_|_){
@@ -129,6 +136,7 @@ Result:
129136
3: (_|_){
130137
// [eval] e5.3: invalid value 8 (out of bound <=5):
131138
// ./in.cue:8:39
139+
// ./in.cue:8:18
132140
}
133141
}
134142
}

cue/testdata/basicrewrite/013_obj_unify.txtar

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ e: _|_ // conflicting values 1 and {a: 3} (mismatched types int and struct)
7575
}
7676
-- out/eval --
7777
Errors:
78-
e: conflicting values 1 and {a:3} (mismatched types int and struct)
78+
e: conflicting values 1 and {a:3} (mismatched types int and struct):
79+
./in.cue:7:5
80+
./in.cue:8:4
7981

8082
Result:
8183
(_|_){
@@ -97,7 +99,9 @@ Result:
9799
b: (int){ 2 }
98100
}
99101
e: (_|_){
100-
// [eval] e: conflicting values 1 and {a:3} (mismatched types int and struct)
102+
// [eval] e: conflicting values 1 and {a:3} (mismatched types int and struct):
103+
// ./in.cue:7:5
104+
// ./in.cue:8:4
101105
a: (int){ 3 }
102106
}
103107
}

0 commit comments

Comments
 (0)