Skip to content

Commit

Permalink
feat(common): Add contexts to the error messages (#6526)
Browse files Browse the repository at this point in the history
**Description:**

This PR makes the error reporter print contexts.

**Related issue:**

 - #6525.
  • Loading branch information
kdy1 committed Nov 28, 2022
1 parent 96a1f93 commit b8fe04f
Show file tree
Hide file tree
Showing 1,858 changed files with 239,444 additions and 116,470 deletions.
254 changes: 172 additions & 82 deletions crates/swc/tests/errors/lints/const-assign/1/output.swc-stderr

Large diffs are not rendered by default.

151 changes: 114 additions & 37 deletions crates/swc/tests/errors/lints/const-assign/2/output.swc-stderr
Expand Up @@ -9,48 +9,62 @@
4 |
5 | foo = 1;
: ^^^
`----

x cannot reassign to an imported binding
,-[2:1]
2 | import bar from "bar";
: ^|^
: `-- imported binding
3 | import * as baz from "baz";
4 |
5 | foo = 1;
6 | bar = 2;
: ^^^
`----

x cannot reassign to an imported binding
,-[3:1]
3 | import * as baz from "baz";
: ^|^
: `-- imported binding
4 |
5 | foo = 1;
6 | bar = 2;
7 | baz = 3;
: ^^^
`----

x cannot reassign to an imported binding
,-[1:1]
1 | import { foo } from "foo";
: ^|^
: `-- imported binding
2 | import bar from "bar";
: ^|^
: `-- imported binding
3 | import * as baz from "baz";
4 |
5 | foo = 1;
6 | bar = 2;
: ^^^
7 | baz = 3;
8 |
9 | foo++;
: ^^^
`----

x cannot reassign to an imported binding
,-[1:1]
1 | import { foo } from "foo";
2 | import bar from "bar";
3 | import * as baz from "baz";
: ^|^
: `-- imported binding
4 |
5 | foo = 1;
6 | bar = 2;
7 | baz = 3;
: ^^^
8 |
9 | foo++;
10 | foo--;
`----

x cannot reassign to an imported binding
,-[1:1]
1 | import { foo } from "foo";
: ^|^
: `-- imported binding
2 | import bar from "bar";
3 | import * as baz from "baz";
4 |
5 | foo = 1;
6 | bar = 2;
7 | baz = 3;
8 |
9 | foo++;
: ^^^
10 | foo--;
11 |
12 | ++bar;
`----

x cannot reassign to an imported binding
,-[1:1]
1 | import { foo } from "foo";
Expand All @@ -66,10 +80,14 @@
9 | foo++;
10 | foo--;
: ^^^
11 |
12 | ++bar;
13 | --bar;
`----

x cannot reassign to an imported binding
,-[2:1]
,-[1:1]
1 | import { foo } from "foo";
2 | import bar from "bar";
: ^|^
: `-- imported binding
Expand All @@ -84,10 +102,13 @@
11 |
12 | ++bar;
: ^^^
13 | --bar;
14 |
`----

x cannot reassign to an imported binding
,-[2:1]
,-[1:1]
1 | import { foo } from "foo";
2 | import bar from "bar";
: ^|^
: `-- imported binding
Expand All @@ -103,6 +124,9 @@
12 | ++bar;
13 | --bar;
: ^^^
14 |
15 |
16 | foo += 10;
`----

x cannot reassign to an imported binding
Expand All @@ -126,10 +150,14 @@
15 |
16 | foo += 10;
: ^^^
17 | bar -= 10;
18 | baz *= 10;
19 | foo /= 10;
`----

x cannot reassign to an imported binding
,-[2:1]
,-[1:1]
1 | import { foo } from "foo";
2 | import bar from "bar";
: ^|^
: `-- imported binding
Expand All @@ -149,10 +177,15 @@
16 | foo += 10;
17 | bar -= 10;
: ^^^
18 | baz *= 10;
19 | foo /= 10;
20 | bar %= 10;
`----

x cannot reassign to an imported binding
,-[3:1]
,-[1:1]
1 | import { foo } from "foo";
2 | import bar from "bar";
3 | import * as baz from "baz";
: ^|^
: `-- imported binding
Expand All @@ -172,6 +205,8 @@
17 | bar -= 10;
18 | baz *= 10;
: ^^^
19 | foo /= 10;
20 | bar %= 10;
`----

x cannot reassign to an imported binding
Expand All @@ -198,10 +233,14 @@
18 | baz *= 10;
19 | foo /= 10;
: ^^^
20 | bar %= 10;
21 |
22 | baz <<= 10;
`----

x cannot reassign to an imported binding
,-[2:1]
,-[1:1]
1 | import { foo } from "foo";
2 | import bar from "bar";
: ^|^
: `-- imported binding
Expand All @@ -224,10 +263,15 @@
19 | foo /= 10;
20 | bar %= 10;
: ^^^
21 |
22 | baz <<= 10;
23 | foo >>= 10;
`----

x cannot reassign to an imported binding
,-[3:1]
,-[1:1]
1 | import { foo } from "foo";
2 | import bar from "bar";
3 | import * as baz from "baz";
: ^|^
: `-- imported binding
Expand All @@ -251,6 +295,9 @@
21 |
22 | baz <<= 10;
: ^^^
23 | foo >>= 10;
24 |
25 | bar >>>= 10;
`----

x cannot reassign to an imported binding
Expand Down Expand Up @@ -281,10 +328,13 @@
22 | baz <<= 10;
23 | foo >>= 10;
: ^^^
24 |
25 | bar >>>= 10;
`----

x cannot reassign to an imported binding
,-[2:1]
,-[1:1]
1 | import { foo } from "foo";
2 | import bar from "bar";
: ^|^
: `-- imported binding
Expand Down Expand Up @@ -312,10 +362,15 @@
24 |
25 | bar >>>= 10;
: ^^^
26 |
27 | baz |= 10;
28 | foo ^= 10;
`----

x cannot reassign to an imported binding
,-[3:1]
,-[1:1]
1 | import { foo } from "foo";
2 | import bar from "bar";
3 | import * as baz from "baz";
: ^|^
: `-- imported binding
Expand Down Expand Up @@ -344,6 +399,9 @@
26 |
27 | baz |= 10;
: ^^^
28 | foo ^= 10;
29 | bar &= 10;
30 | baz **= 10;
`----

x cannot reassign to an imported binding
Expand Down Expand Up @@ -379,10 +437,13 @@
27 | baz |= 10;
28 | foo ^= 10;
: ^^^
29 | bar &= 10;
30 | baz **= 10;
`----

x cannot reassign to an imported binding
,-[2:1]
,-[1:1]
1 | import { foo } from "foo";
2 | import bar from "bar";
: ^|^
: `-- imported binding
Expand Down Expand Up @@ -414,10 +475,15 @@
28 | foo ^= 10;
29 | bar &= 10;
: ^^^
30 | baz **= 10;
31 |
32 | foo &&= 10;
`----

x cannot reassign to an imported binding
,-[3:1]
,-[1:1]
1 | import { foo } from "foo";
2 | import bar from "bar";
3 | import * as baz from "baz";
: ^|^
: `-- imported binding
Expand Down Expand Up @@ -449,6 +515,9 @@
29 | bar &= 10;
30 | baz **= 10;
: ^^^
31 |
32 | foo &&= 10;
33 | bar ||= 10;
`----

x cannot reassign to an imported binding
Expand Down Expand Up @@ -488,10 +557,14 @@
31 |
32 | foo &&= 10;
: ^^^
33 | bar ||= 10;
34 |
35 | baz ??= 10;
`----

x cannot reassign to an imported binding
,-[2:1]
,-[1:1]
1 | import { foo } from "foo";
2 | import bar from "bar";
: ^|^
: `-- imported binding
Expand Down Expand Up @@ -527,10 +600,14 @@
32 | foo &&= 10;
33 | bar ||= 10;
: ^^^
34 |
35 | baz ??= 10;
`----

x cannot reassign to an imported binding
,-[3:1]
,-[1:1]
1 | import { foo } from "foo";
2 | import bar from "bar";
3 | import * as baz from "baz";
: ^|^
: `-- imported binding
Expand Down

1 comment on commit b8fe04f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: b8fe04f Previous: 47908a4 Ratio
es/full/bugs-1 399120 ns/iter (± 52162) 391138 ns/iter (± 125747) 1.02
es/full/minify/libraries/antd 1993023368 ns/iter (± 44891391) 2173161351 ns/iter (± 71595469) 0.92
es/full/minify/libraries/d3 486241169 ns/iter (± 30508753) 492381330 ns/iter (± 34719725) 0.99
es/full/minify/libraries/echarts 1738037462 ns/iter (± 52651405) 1771885198 ns/iter (± 79964702) 0.98
es/full/minify/libraries/jquery 120839543 ns/iter (± 6184030) 119091830 ns/iter (± 5908570) 1.01
es/full/minify/libraries/lodash 138878875 ns/iter (± 5627895) 129430278 ns/iter (± 4953714) 1.07
es/full/minify/libraries/moment 69705182 ns/iter (± 3568091) 66036132 ns/iter (± 1596100) 1.06
es/full/minify/libraries/react 22283327 ns/iter (± 470802) 22741537 ns/iter (± 3032009) 0.98
es/full/minify/libraries/terser 392040037 ns/iter (± 26457884) 363410825 ns/iter (± 9358258) 1.08
es/full/minify/libraries/three 638024730 ns/iter (± 48645090) 668735226 ns/iter (± 21672065) 0.95
es/full/minify/libraries/typescript 3665441927 ns/iter (± 44857092) 3983337552 ns/iter (± 26936780) 0.92
es/full/minify/libraries/victory 887616584 ns/iter (± 30196126) 971160298 ns/iter (± 22086738) 0.91
es/full/minify/libraries/vue 182198013 ns/iter (± 12943376) 184788200 ns/iter (± 6651278) 0.99
es/full/codegen/es3 32911 ns/iter (± 990) 34304 ns/iter (± 7708) 0.96
es/full/codegen/es5 33126 ns/iter (± 716) 33904 ns/iter (± 2633) 0.98
es/full/codegen/es2015 33183 ns/iter (± 824) 33768 ns/iter (± 717) 0.98
es/full/codegen/es2016 33153 ns/iter (± 965) 33778 ns/iter (± 1430) 0.98
es/full/codegen/es2017 33123 ns/iter (± 1507) 33697 ns/iter (± 1972) 0.98
es/full/codegen/es2018 33038 ns/iter (± 537) 33597 ns/iter (± 305) 0.98
es/full/codegen/es2019 33088 ns/iter (± 276) 33691 ns/iter (± 364) 0.98
es/full/codegen/es2020 34985 ns/iter (± 7037) 33694 ns/iter (± 280) 1.04
es/full/all/es3 192441456 ns/iter (± 21713845) 191229107 ns/iter (± 11287539) 1.01
es/full/all/es5 185760146 ns/iter (± 10959542) 177967707 ns/iter (± 8394351) 1.04
es/full/all/es2015 148849281 ns/iter (± 15487614) 147053590 ns/iter (± 8506577) 1.01
es/full/all/es2016 151247700 ns/iter (± 12194811) 145335693 ns/iter (± 6541120) 1.04
es/full/all/es2017 136116902 ns/iter (± 5166314) 148985568 ns/iter (± 14271004) 0.91
es/full/all/es2018 135576049 ns/iter (± 14456838) 157269652 ns/iter (± 15653162) 0.86
es/full/all/es2019 137973891 ns/iter (± 6703669) 139370021 ns/iter (± 9452236) 0.99
es/full/all/es2020 134284640 ns/iter (± 10302669) 137019533 ns/iter (± 7781730) 0.98
es/full/parser 723394 ns/iter (± 58722) 688236 ns/iter (± 33180) 1.05
es/full/base/fixer 26359 ns/iter (± 1384) 25801 ns/iter (± 1006) 1.02
es/full/base/resolver_and_hygiene 91198 ns/iter (± 7217) 90790 ns/iter (± 7772) 1.00
serialization of ast node 218 ns/iter (± 6) 205 ns/iter (± 4) 1.06
serialization of serde 223 ns/iter (± 11) 212 ns/iter (± 5) 1.05

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.