this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/core/adt: dedup errors

Change-Id: I335f7d22c76fb16200b98f9c1f3c7e3712b267aa
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9448
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>

+48 -46
+5 -5
cue/builtin_test.go
··· 62 62 `16`, 63 63 }, { 64 64 test("encoding/yaml", `yaml.Validate("a: 2\n---\na: 4", {a:<3})`), 65 - `_|_(error in call to encoding/yaml.Validate: a: invalid value 4 (out of bound <3) (and 1 more errors))`, 65 + `_|_(error in call to encoding/yaml.Validate: a: invalid value 4 (out of bound <3))`, 66 66 }, { 67 67 test("encoding/yaml", `yaml.Validate("a: 2\n---\na: 4", {a:<5})`), 68 68 `true`, 69 69 }, { 70 70 test("encoding/yaml", `yaml.Validate("a: 2\n", {a:<5, b:int})`), 71 - `_|_(error in call to encoding/yaml.Validate: b: incomplete value int (and 1 more errors))`, 71 + `_|_(error in call to encoding/yaml.Validate: b: incomplete value int)`, 72 72 }, { 73 73 test("strconv", `strconv.FormatUint(64, 16)`), 74 74 `"40"`, ··· 77 77 `"foo"`, 78 78 }, { 79 79 test("regexp", `regexp.Find(#"f\w\w"#, "bar")`), 80 - `_|_(error in call to regexp.Find: no match (and 1 more errors))`, 80 + `_|_(error in call to regexp.Find: no match)`, 81 81 }, { 82 82 testExpr(`len([1, 2, 3])`), 83 83 `3`, ··· 92 92 x: int 93 93 y: json.Marshal({a: x}) 94 94 }`), 95 - `{x:int,y:_|_(cannot convert incomplete value "int" to JSON (and 1 more errors))}`, 95 + `{x:int,y:_|_(cannot convert incomplete value "int" to JSON)}`, 96 96 }, { 97 97 test("encoding/yaml", `yaml.MarshalStream([{a: 1}, {b: 2}])`), 98 98 `"a: 1\n---\nb: 2\n"`, ··· 146 146 emit string 147 147 }{{ 148 148 test("list", `list.Sort([{a:1}, {b:2}], list.Ascending)`), 149 - `_|_(error in call to list.Sort: less: invalid operands {b:2} and {a:1} to '<' (type struct and struct) (and 1 more errors))`, 149 + `_|_(error in call to list.Sort: less: invalid operands {b:2} and {a:1} to '<' (type struct and struct))`, 150 150 }} 151 151 for i, tc := range testCases { 152 152 t.Run(fmt.Sprint(i), func(t *testing.T) {
+3 -1
internal/core/adt/context.go
··· 591 591 bb.Err = errors.Wrapf(b.Err, c.src.Pos(), "") 592 592 result = &bb 593 593 } 594 - c.errs = CombineErrors(c.src, c.errs, result) 594 + if c.errs != result { 595 + c.errs = CombineErrors(c.src, c.errs, result) 596 + } 595 597 } 596 598 if c.errs != nil { 597 599 result = c.errs
+2 -2
pkg/encoding/base64/testdata/gen.txtar
··· 15 15 Result: 16 16 t1: "Zm9v" 17 17 t2: 'foo' 18 - t3: _|_ // error in call to encoding/base64.Decode: illegal base64 data at input byte 0 (and 1 more errors) 19 - t4: _|_ // error in call to encoding/base64.Decode: base64: unsupported encoding: cannot use value {} (type struct) as null (and 1 more errors) 18 + t3: _|_ // error in call to encoding/base64.Decode: illegal base64 data at input byte 0 19 + t4: _|_ // error in call to encoding/base64.Decode: base64: unsupported encoding: cannot use value {} (type struct) as null 20 20
+1 -1
pkg/encoding/hex/testdata/gen.txtar
··· 14 14 Result: 15 15 t1: "666f6f" 16 16 t2: 'foo' 17 - t3: _|_ // error in call to encoding/hex.Decode: encoding/hex: invalid byte: U+006F 'o' (and 1 more errors) 17 + t3: _|_ // error in call to encoding/hex.Decode: encoding/hex: invalid byte: U+006F 'o' 18 18 t4: """ 19 19 00000000 66 6f 6f |foo| 20 20
+1 -1
pkg/encoding/json/testdata/gen.txtar
··· 25 25 import "encoding/json" 26 26 27 27 t1: true 28 - t2: _|_ // error in call to encoding/json.Validate: a: invalid value 10 (out of bound <3) (and 1 more errors) 28 + t2: _|_ // error in call to encoding/json.Validate: a: invalid value 10 (out of bound <3) 29 29 t3: true 30 30 t4: "[1,2]" 31 31 t5: """
+3 -3
pkg/encoding/yaml/testdata/gen.txtar
··· 23 23 yaml.ValidatePartial:3:5 24 24 25 25 Result: 26 - t1: _|_ // error in call to encoding/yaml.Validate: a: invalid value 4 (out of bound <3) (and 1 more errors) 26 + t1: _|_ // error in call to encoding/yaml.Validate: a: invalid value 4 (out of bound <3) 27 27 t2: true 28 - t3: _|_ // error in call to encoding/yaml.Validate: b: incomplete value int (and 1 more errors) 29 - t4: _|_ // error in call to encoding/yaml.ValidatePartial: a: invalid value 4 (out of bound <3) (and 1 more errors) 28 + t3: _|_ // error in call to encoding/yaml.Validate: b: incomplete value int 29 + t4: _|_ // error in call to encoding/yaml.ValidatePartial: a: invalid value 4 (out of bound <3) 30 30 t5: true 31 31 t6: true 32 32 t7: """
+19 -19
pkg/list/testdata/gen.txtar
··· 79 79 ./in.cue:46:24 80 80 list:10:9 81 81 Ascending.x: error in call to list.Sort: conflicting values string and {b:2} (mismatched types string and struct): 82 - ./in.cue:46:24 82 + ./in.cue:60:24 83 83 list:10:18 84 84 Ascending.y: error in call to list.Sort: 2 errors in empty disjunction: 85 85 Ascending.y: error in call to list.Sort: conflicting values number and {a:1} (mismatched types number and struct): 86 - ./in.cue:46:17 86 + ./in.cue:60:17 87 87 list:10:9 88 88 Ascending.y: error in call to list.Sort: conflicting values string and {a:1} (mismatched types string and struct): 89 - ./in.cue:60:17 89 + ./in.cue:46:17 90 90 list:10:18 91 91 t3: cannot use "foo" (type string) as list in argument 1 to list.Avg: 92 92 ./in.cue:5:14 ··· 107 107 108 108 Result: 109 109 t1: 2.5 110 - t2: _|_ // error in call to list.Avg: empty list (and 1 more errors) 110 + t2: _|_ // error in call to list.Avg: empty list 111 111 t3: _|_ // t3: cannot use "foo" (type string) as list in argument 1 to list.Avg 112 112 t4: [1, 2, 3, 4] 113 113 t5: [3, 4] 114 114 t6: [] 115 - t7: _|_ // error in call to list.Drop: negative index (and 1 more errors) 115 + t7: _|_ // error in call to list.Drop: negative index 116 116 t8: [1, 2, 3, 4] 117 117 t9: [1, [[2, 3], []], [4]] 118 118 t10: [1, [2, 3], [], 4] 119 119 t11: [1, 2, 3, 4] 120 120 t12: [] 121 - t13: _|_ // error in call to list.FlattenN: cannot use value "foo" (type string) as list (and 1 more errors) 121 + t13: _|_ // error in call to list.FlattenN: cannot use value "foo" (type string) as list 122 122 t14: _|_ // t14: cannot use "foo" (type string) as int in argument 2 to list.FlattenN 123 123 t15: 4 124 - t16: _|_ // error in call to list.Max: empty list (and 1 more errors) 124 + t16: _|_ // error in call to list.Max: empty list 125 125 t17: _|_ // t17: cannot use "foo" (type string) as list in argument 1 to list.Max 126 126 t18: 1 127 - t19: _|_ // error in call to list.Min: empty list (and 1 more errors) 127 + t19: _|_ // error in call to list.Min: empty list 128 128 t20: _|_ // t20: cannot use "foo" (type string) as list in argument 1 to list.Min 129 129 t21: 24 130 130 t22: 1 131 131 t23: _|_ // t23: cannot use "foo" (type string) as list in argument 1 to list.Product 132 - t24: _|_ // error in call to list.Range: step must be non zero (and 1 more errors) 133 - t25: _|_ // error in call to list.Range: end must be greater than start when step is positive (and 1 more errors) 134 - t26: _|_ // error in call to list.Range: end must be less than start when step is negative (and 1 more errors) 132 + t24: _|_ // error in call to list.Range: step must be non zero 133 + t25: _|_ // error in call to list.Range: end must be greater than start when step is positive 134 + t26: _|_ // error in call to list.Range: end must be less than start when step is negative 135 135 t27: [0, 1, 2, 3, 4] 136 136 t28: [0] 137 137 t29: [0, 2, 4] 138 138 t30: [5, 4, 3, 2, 1] 139 139 t31: [0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5] 140 140 t32: [2, 3] 141 - t33: _|_ // error in call to list.Slice: negative index (and 1 more errors) 142 - t34: _|_ // error in call to list.Slice: invalid index: 3 > 1 (and 1 more errors) 143 - t35: _|_ // error in call to list.Slice: slice bounds out of range (and 1 more errors) 144 - t36: _|_ // error in call to list.Slice: slice bounds out of range (and 1 more errors) 141 + t33: _|_ // error in call to list.Slice: negative index 142 + t34: _|_ // error in call to list.Slice: invalid index: 3 > 1 143 + t35: _|_ // error in call to list.Slice: slice bounds out of range 144 + t36: _|_ // error in call to list.Slice: slice bounds out of range 145 145 t37: [] 146 146 t38: [1, 2, 3, 4] 147 147 t39: [{ ··· 154 154 a: 2 155 155 v: 1 156 156 }] 157 - t40: _|_ // error in call to list.Sort: Ascending.x: 2 errors in empty disjunction: (and 11 more errors) 157 + t40: _|_ // error in call to list.Sort: Ascending.x: 2 errors in empty disjunction: (and 5 more errors) 158 158 t41: ["a", "b"] 159 - t42: _|_ // t42: invalid type element 0 (int) of string list argument 0 (and 1 more errors) 159 + t42: _|_ // t42: invalid type element 0 (int) of string list argument 0 160 160 t43: 10 161 161 t44: 0 162 162 t45: _|_ // t45: cannot use "foo" (type string) as list in argument 1 to list.Sum 163 163 t46: [] 164 164 t47: [1, 2] 165 165 t48: [1, 2, 3, 4] 166 - t49: _|_ // error in call to list.Take: negative index (and 1 more errors) 166 + t49: _|_ // error in call to list.Take: negative index 167 167 t50: true 168 168 t51: false 169 169 t52: true 170 170 t53: false 171 - t54: _|_ // error in call to list.Sort: Ascending.x: 2 errors in empty disjunction: (and 11 more errors) 171 + t54: _|_ // error in call to list.Sort: Ascending.x: 2 errors in empty disjunction: (and 5 more errors) 172 172
+2 -2
pkg/list/testdata/list.txtar
··· 89 89 t8: { 90 90 x: [1] 91 91 n: -1 92 - v: _|_ // error in call to list.Repeat: negative count (and 1 more errors) 92 + v: _|_ // error in call to list.Repeat: negative count 93 93 } 94 94 } 95 95 concat: { ··· 123 123 } 124 124 t8: { 125 125 x: [1, [2]] 126 - v: _|_ // error in call to list.Concat: cannot use value 1 (type int) as list (and 1 more errors) 126 + v: _|_ // error in call to list.Concat: cannot use value 1 (type int) as list 127 127 } 128 128 } 129 129 unique: {
+2 -2
pkg/math/testdata/gen.txtar
··· 36 36 t1: 3.14159265358979323846264338327950288419716939937510582097494459 37 37 t2: 3 38 38 t3: _|_ // t3: cannot call non-function math.Pi (type float) 39 - t6: _|_ // error in call to math.Jacobi: big: invalid 2nd argument to Int.Jacobi: need odd integer but got 2000 (and 1 more errors) 39 + t6: _|_ // error in call to math.Jacobi: big: invalid 2nd argument to Int.Jacobi: need odd integer but got 2000 40 40 t7: 1 41 - t8: _|_ // cannot use 2.0E+400 (type float) as float64 in argument 0 to math.Asin: value was rounded up (and 1 more errors) 41 + t8: _|_ // cannot use 2.0E+400 (type float) as float64 in argument 0 to math.Asin: value was rounded up 42 42 t16: 4096 43 43 t17: 1e+4 44 44 t18: true
+1 -1
pkg/math/testdata/round.txtar
··· 44 44 mul0: true 45 45 mul1: false 46 46 // TODO(errors): ensure path is included for the following error. 47 - mul2: _|_ // error in call to math.MultipleOf: division by zero (and 1 more errors) 47 + mul2: _|_ // error in call to math.MultipleOf: division by zero 48 48 mul3: false 49 49 mul4: true 50 50 mul5: true
+1 -1
pkg/net/testdata/gen.txtar
··· 36 36 t4: "example.com:80" 37 37 t5: "[2001:db8::1]:80" 38 38 t6: "192.30.4.2:80" 39 - t7: _|_ // error in call to net.JoinHostPort: invalid host [192, 30, 4] (and 1 more errors) 39 + t7: _|_ // error in call to net.JoinHostPort: invalid host [192, 30, 4] 40 40 t8: true 41 41 t9: _|_ // t9: invalid value "23.23.23.2333" (does not satisfy net.IPv4) 42 42 t10: true
+1 -1
pkg/path/testdata/error.txtar
··· 26 26 27 27 Result: 28 28 joinOK: "a/b" 29 - joinErr: _|_ // joinErr: cannot use "foo" as *"unix" | "windows" | "plan9" | "aix" | "android" | "darwin" | "dragonfly" | "freebsd" | "hurd" | "illumos" | "ios" | "js" | "linux" | "nacl" | "netbsd" | "openbsd" | "solaris" | "zos" in argument 2 to path.Join (and 3 more errors) 29 + joinErr: _|_ // joinErr: cannot use "foo" as *"unix" | "windows" | "plan9" | "aix" | "android" | "darwin" | "dragonfly" | "freebsd" | "hurd" | "illumos" | "ios" | "js" | "linux" | "nacl" | "netbsd" | "openbsd" | "solaris" | "zos" in argument 2 to path.Join (and 1 more errors) 30 30
+4 -4
pkg/regexp/testdata/gen.txtar
··· 28 28 29 29 Result: 30 30 t1: "foo" 31 - t2: _|_ // error in call to regexp.Find: no match (and 1 more errors) 31 + t2: _|_ // error in call to regexp.Find: no match 32 32 t3: ["foo", "flo"] 33 33 t4: ["foo", "flo"] 34 - t5: _|_ // error in call to regexp.FindAll: no match (and 1 more errors) 34 + t5: _|_ // error in call to regexp.FindAll: no match 35 35 t6: ["flo", "l", "o"] 36 36 t7: [["flo", "l", "o"], ["foo", "o", "o"], ["fro", "r", "o"]] 37 - t8: _|_ // error in call to regexp.FindAllSubmatch: no match (and 1 more errors) 37 + t8: _|_ // error in call to regexp.FindAllSubmatch: no match 38 38 t9: { 39 39 A: "l" 40 40 B: "o" ··· 52 52 t11: [{ 53 53 A: "" 54 54 }] 55 - t12: _|_ // error in call to regexp.FindAllNamedSubmatch: no match (and 1 more errors) 55 + t12: _|_ // error in call to regexp.FindAllNamedSubmatch: no match 56 56 t13: "valid" 57 57 t14: _|_ // t14: invalid value "invalid)" (does not satisfy regexp.Valid): error in call to regexp.Valid: error parsing regexp: unexpected ): `invalid)` 58 58
+2 -2
pkg/strconv/testdata/gen.txtar
··· 19 19 20 20 Result: 21 21 t1: "40" 22 - t2: _|_ // int 300 overflows byte in argument 1 in call to strconv.FormatFloat (and 1 more errors) 23 - t3: _|_ // cannot use -1 (type int) as byte in argument 1 to strconv.FormatFloat (and 1 more errors) 22 + t2: _|_ // int 300 overflows byte in argument 1 in call to strconv.FormatFloat 23 + t3: _|_ // cannot use -1 (type int) as byte in argument 1 to strconv.FormatFloat 24 24 t4: _|_ // t4: cannot use 1.0 (type float) as int in argument 2 to strconv.FormatFloat 25 25 t5: "true" 26 26
+1 -1
pkg/strings/testdata/gen.txtar
··· 43 43 44 44 Result: 45 45 t1: "Hello World!" 46 - t2: _|_ // t2: invalid type element 0 (int) of string list argument 0 (and 1 more errors) 46 + t2: _|_ // t2: invalid type element 0 (int) of string list argument 0 47 47 t3: 97 48 48 t4: 'llo' 49 49 t5: "✓ H"