Skip to content

Commit

Permalink
internal/core/adt: add path location for majority of errors
Browse files Browse the repository at this point in the history
Change-Id: I8a7b19851af88ecd09ae9032d659ade3570b73e3
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6650
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
mpvl committed Jul 23, 2020
1 parent 5a51083 commit 651d379
Show file tree
Hide file tree
Showing 94 changed files with 583 additions and 440 deletions.
18 changes: 10 additions & 8 deletions cue/testdata/basicrewrite/001_regexp.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ e3: _|_ // conflicting values !="a" and <5 (mismatched types string and number)
}
-- out/eval --
Errors:
invalid value "foo" (out of bound =~"[a-z]{4}")
invalid value <5 (mismatched types number and string)
cannot use 1 (type int) as type (string|bytes):
e3: invalid value <5 (mismatched types number and string)
b3: invalid value "foo" (out of bound =~"[a-z]{4}"):
./in.cue:10:5
e1: cannot use 1 (type int) as type (string|bytes):
./in.cue:18:5
cannot use true (type bool) as type (string|bytes):
e2: cannot use true (type bool) as type (string|bytes):
./in.cue:19:5

Result:
Expand All @@ -79,20 +80,21 @@ Result:
b1: (string){ "a" }
b2: (string){ "foo" }
b3: (_|_){
// [eval] invalid value "foo" (out of bound =~"[a-z]{4}")
// [eval] b3: invalid value "foo" (out of bound =~"[a-z]{4}"):
// ./in.cue:10:5
}
b4: (string){ "foo" }
s1: (string){ &(!="b", =~"c") }
s2: (string){ &(!="b", =~"[a-z]") }
e1: (_|_){
// [eval] cannot use 1 (type int) as type (string|bytes):
// [eval] e1: cannot use 1 (type int) as type (string|bytes):
// ./in.cue:18:5
}
e2: (_|_){
// [eval] cannot use true (type bool) as type (string|bytes):
// [eval] e2: cannot use true (type bool) as type (string|bytes):
// ./in.cue:19:5
}
e3: (_|_){
// [eval] invalid value <5 (mismatched types number and string)
// [eval] e3: invalid value <5 (mismatched types number and string)
}
}
44 changes: 22 additions & 22 deletions cue/testdata/basicrewrite/002_arithmetic.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,27 @@ e8: _|_ // invalid operation 1.0 mod 1 (mismatched types float and int)
}
-- out/eval --
Errors:
failed arithmetic: division by zero:
divZero: failed arithmetic: division by zero:
./in.cue:8:10
failed arithmetic: division undefined:
div00: failed arithmetic: division undefined:
./in.cue:9:10
division by zero:
idiv00: division by zero:
./in.cue:13:9
division by zero:
imod00: division by zero:
./in.cue:14:9
division by zero:
iquo00: division by zero:
./in.cue:15:9
division by zero:
irem00: division by zero:
./in.cue:16:9
invalid operands 2 and "a" to '+' (type int and string):
e0: invalid operands 2 and "a" to '+' (type int and string):
./in.cue:23:5
invalid operands 1.0 and 2 to 'div' (type float and int):
e5: invalid operands 1.0 and 2 to 'div' (type float and int):
./in.cue:29:5
invalid operands 2 and 2.0 to 'rem' (type int and float):
e6: invalid operands 2 and 2.0 to 'rem' (type int and float):
./in.cue:30:5
invalid operands 2 and 2.0 to 'quo' (type int and float):
e7: invalid operands 2 and 2.0 to 'quo' (type int and float):
./in.cue:31:5
invalid operands 1.0 and 1 to 'mod' (type float and int):
e8: invalid operands 1.0 and 1 to 'mod' (type float and int):
./in.cue:32:5

Result:
Expand All @@ -128,53 +128,53 @@ Result:
div2: (float){ 4.00000000000000000000000 }
div3: (float){ 1 }
divZero: (_|_){
// [eval] failed arithmetic: division by zero:
// [eval] divZero: failed arithmetic: division by zero:
// ./in.cue:8:10
}
div00: (_|_){
// [eval] failed arithmetic: division undefined:
// [eval] div00: failed arithmetic: division undefined:
// ./in.cue:9:10
}
b: (bool){ true }
add: (float){ 5.00000000000000000000000 }
idiv00: (_|_){
// [eval] division by zero:
// [eval] idiv00: division by zero:
// ./in.cue:13:9
}
imod00: (_|_){
// [eval] division by zero:
// [eval] imod00: division by zero:
// ./in.cue:14:9
}
iquo00: (_|_){
// [eval] division by zero:
// [eval] iquo00: division by zero:
// ./in.cue:15:9
}
irem00: (_|_){
// [eval] division by zero:
// [eval] irem00: division by zero:
// ./in.cue:16:9
}
v1: (float){ 5.0000000000E+11 }
v2: (bool){ true }
v3: (float){ 0.666666666666666666666667 }
v5: (int){ 0 }
e0: (_|_){
// [eval] invalid operands 2 and "a" to '+' (type int and string):
// [eval] e0: invalid operands 2 and "a" to '+' (type int and string):
// ./in.cue:23:5
}
e5: (_|_){
// [eval] invalid operands 1.0 and 2 to 'div' (type float and int):
// [eval] e5: invalid operands 1.0 and 2 to 'div' (type float and int):
// ./in.cue:29:5
}
e6: (_|_){
// [eval] invalid operands 2 and 2.0 to 'rem' (type int and float):
// [eval] e6: invalid operands 2 and 2.0 to 'rem' (type int and float):
// ./in.cue:30:5
}
e7: (_|_){
// [eval] invalid operands 2 and 2.0 to 'quo' (type int and float):
// [eval] e7: invalid operands 2 and 2.0 to 'quo' (type int and float):
// ./in.cue:31:5
}
e8: (_|_){
// [eval] invalid operands 1.0 and 1 to 'mod' (type float and int):
// [eval] e8: invalid operands 1.0 and 1 to 'mod' (type float and int):
// ./in.cue:32:5
}
}
32 changes: 16 additions & 16 deletions cue/testdata/basicrewrite/003_integer-specific_arithmetic.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,21 @@ me2: _|_ // invalid operation 2 mod 1.0 (mismatched types int and float)
}
-- out/eval --
Errors:
invalid operands 2.0 and 1 to 'quo' (type float and int):
qe1: invalid operands 2.0 and 1 to 'quo' (type float and int):
./in.cue:5:6
invalid operands 2 and 1.0 to 'quo' (type int and float):
qe2: invalid operands 2 and 1.0 to 'quo' (type int and float):
./in.cue:6:6
invalid operands 2.0 and 1 to 'rem' (type float and int):
re1: invalid operands 2.0 and 1 to 'rem' (type float and int):
./in.cue:12:6
invalid operands 2 and 1.0 to 'rem' (type int and float):
re2: invalid operands 2 and 1.0 to 'rem' (type int and float):
./in.cue:13:6
invalid operands 2.0 and 1 to 'div' (type float and int):
de1: invalid operands 2.0 and 1 to 'div' (type float and int):
./in.cue:19:6
invalid operands 2 and 1.0 to 'div' (type int and float):
de2: invalid operands 2 and 1.0 to 'div' (type int and float):
./in.cue:20:6
invalid operands 2.0 and 1 to 'mod' (type float and int):
me1: invalid operands 2.0 and 1 to 'mod' (type float and int):
./in.cue:26:6
invalid operands 2 and 1.0 to 'mod' (type int and float):
me2: invalid operands 2 and 1.0 to 'mod' (type int and float):
./in.cue:27:6

Result:
Expand All @@ -112,47 +112,47 @@ Result:
q3: (int){ -2 }
q4: (int){ 2 }
qe1: (_|_){
// [eval] invalid operands 2.0 and 1 to 'quo' (type float and int):
// [eval] qe1: invalid operands 2.0 and 1 to 'quo' (type float and int):
// ./in.cue:5:6
}
qe2: (_|_){
// [eval] invalid operands 2 and 1.0 to 'quo' (type int and float):
// [eval] qe2: invalid operands 2 and 1.0 to 'quo' (type int and float):
// ./in.cue:6:6
}
r1: (int){ 1 }
r2: (int){ 1 }
r3: (int){ -1 }
r4: (int){ -1 }
re1: (_|_){
// [eval] invalid operands 2.0 and 1 to 'rem' (type float and int):
// [eval] re1: invalid operands 2.0 and 1 to 'rem' (type float and int):
// ./in.cue:12:6
}
re2: (_|_){
// [eval] invalid operands 2 and 1.0 to 'rem' (type int and float):
// [eval] re2: invalid operands 2 and 1.0 to 'rem' (type int and float):
// ./in.cue:13:6
}
d1: (int){ 2 }
d2: (int){ -2 }
d3: (int){ -3 }
d4: (int){ 3 }
de1: (_|_){
// [eval] invalid operands 2.0 and 1 to 'div' (type float and int):
// [eval] de1: invalid operands 2.0 and 1 to 'div' (type float and int):
// ./in.cue:19:6
}
de2: (_|_){
// [eval] invalid operands 2 and 1.0 to 'div' (type int and float):
// [eval] de2: invalid operands 2 and 1.0 to 'div' (type int and float):
// ./in.cue:20:6
}
m1: (int){ 1 }
m2: (int){ 1 }
m3: (int){ 1 }
m4: (int){ 1 }
me1: (_|_){
// [eval] invalid operands 2.0 and 1 to 'mod' (type float and int):
// [eval] me1: invalid operands 2.0 and 1 to 'mod' (type float and int):
// ./in.cue:26:6
}
me2: (_|_){
// [eval] invalid operands 2 and 1.0 to 'mod' (type int and float):
// [eval] me2: invalid operands 2 and 1.0 to 'mod' (type int and float):
// ./in.cue:27:6
}
}
4 changes: 2 additions & 2 deletions cue/testdata/basicrewrite/004_booleans.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ e: _|_ // conflicting values true and false
}
-- out/eval --
Errors:
incompatible values false and true
e: incompatible values false and true

Result:
(_|_){
// [eval]
t: (bool){ true }
f: (bool){ false }
e: (_|_){
// [eval] incompatible values false and true
// [eval] e: incompatible values false and true
}
}
4 changes: 2 additions & 2 deletions cue/testdata/basicrewrite/005_boolean_arithmetic.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ f: _|_ // conflicting values true and false
}
-- out/eval --
Errors:
incompatible values false and true
f: incompatible values false and true

Result:
(_|_){
Expand All @@ -41,6 +41,6 @@ Result:
d: (bool){ true }
e: (bool){ true }
f: (_|_){
// [eval] incompatible values false and true
// [eval] f: incompatible values false and true
}
}
4 changes: 2 additions & 2 deletions cue/testdata/basicrewrite/006_basic_type.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ f: true
}
-- out/eval --
Errors:
invalid value float (mismatched types float and int)
d: invalid value float (mismatched types float and int)

Result:
(_|_){
Expand All @@ -43,7 +43,7 @@ Result:
b: (int){ 1 }
c: (float){ 1.0 }
d: (_|_){
// [eval] invalid value float (mismatched types float and int)
// [eval] d: invalid value float (mismatched types float and int)
}
e: (string){ "4" }
f: (bool){ true }
Expand Down
8 changes: 4 additions & 4 deletions cue/testdata/basicrewrite/007_strings_and_bytes.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ e1: _|_ // invalid operation 'b' + "c" (mismatched types bytes and string)
}
-- out/eval --
Errors:
invalid operands "a" and '' to '+' (type string and bytes):
e0: invalid operands "a" and '' to '+' (type string and bytes):
./in.cue:10:5
invalid operands 'b' and "c" to '+' (type bytes and string):
e1: invalid operands 'b' and "c" to '+' (type bytes and string):
./in.cue:11:5

Result:
Expand All @@ -56,11 +56,11 @@ Result:
b1: (bytes){ 'abcabcabc' }
b2: (bytes){ 'abcabc' }
e0: (_|_){
// [eval] invalid operands "a" and '' to '+' (type string and bytes):
// [eval] e0: invalid operands "a" and '' to '+' (type string and bytes):
// ./in.cue:10:5
}
e1: (_|_){
// [eval] invalid operands 'b' and "c" to '+' (type bytes and string):
// [eval] e1: invalid operands 'b' and "c" to '+' (type bytes and string):
// ./in.cue:11:5
}
}
23 changes: 14 additions & 9 deletions cue/testdata/basicrewrite/010_lists.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,15 @@ e5: [1, 2, 4, _|_, // invalid value 8 (out of bound <=5)
}
-- out/eval --
Errors:
conflicting types
invalid value 8 (out of bound <=5)
invalid list index d (type string):
e: conflicting types list and int
e2: invalid list index d (type string):
./in.cue:5:12
invalid negative index -1:
e3: invalid negative index -1:
./in.cue:6:8
e4.3: invalid value 8 (out of bound <=5):
./in.cue:7:24
e5.3: invalid value 8 (out of bound <=5):
./in.cue:8:39

Result:
(_|_){
Expand All @@ -98,14 +101,14 @@ Result:
2: (int){ 3 }
}
e: (_|_){
// [eval] conflicting types
// [eval] e: conflicting types list and int
}
e2: (_|_){
// [eval] invalid list index d (type string):
// [eval] e2: invalid list index d (type string):
// ./in.cue:5:12
}
e3: (_|_){
// [eval] invalid negative index -1:
// [eval] e3: invalid negative index -1:
// ./in.cue:6:8
}
e4: (_|_){
Expand All @@ -114,7 +117,8 @@ Result:
1: (int){ 2 }
2: (int){ 4 }
3: (_|_){
// [eval] invalid value 8 (out of bound <=5)
// [eval] e4.3: invalid value 8 (out of bound <=5):
// ./in.cue:7:24
}
}
e5: (_|_){
Expand All @@ -123,7 +127,8 @@ Result:
1: (int){ 2 }
2: (int){ 4 }
3: (_|_){
// [eval] invalid value 8 (out of bound <=5)
// [eval] e5.3: invalid value 8 (out of bound <=5):
// ./in.cue:8:39
}
}
}
4 changes: 2 additions & 2 deletions cue/testdata/basicrewrite/011_list_arithmetic.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ e: _|_ // negative number -1 multiplies list
}
-- out/eval --
Errors:
cannot convert negative number to uint64:
e: cannot convert negative number to uint64:
./in.cue:10:9

Result:
Expand Down Expand Up @@ -92,7 +92,7 @@ Result:
3: (int){ 1 }
}
e: (_|_){
// [eval] cannot convert negative number to uint64:
// [eval] e: cannot convert negative number to uint64:
// ./in.cue:10:9
}
}

0 comments on commit 651d379

Please sign in to comment.