Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/unique-formal-parameters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
swc_core: patch
swc_ecma_parser: patch
---

fix(es/parser): enforce UniqueFormalParameters for methods, arrows, and non-simple forms
53 changes: 14 additions & 39 deletions crates/swc/tests/errors/lints/no-dupe-args/2/output.swc-stderr
Original file line number Diff line number Diff line change
@@ -1,93 +1,68 @@
x the name `b` is bound more than once in this parameter list
x Duplicate parameter name not allowed in this context: b
,-[1:1]
1 | const foo = (a, b, b) => {};
: | |
: | `-- used as parameter more than once
: `-- previous definition here
: ^
2 | (a, b, b) => {};
3 | ((a, b, b) => {})();
`----
x the name `b` is bound more than once in this parameter list
x Duplicate parameter name not allowed in this context: b
,-[2:1]
1 | const foo = (a, b, b) => {};
2 | (a, b, b) => {};
: | |
: | `-- used as parameter more than once
: `-- previous definition here
: ^
3 | ((a, b, b) => {})();
4 |
5 | class Bar {
`----
x the name `b` is bound more than once in this parameter list
x Duplicate parameter name not allowed in this context: b
,-[3:1]
1 | const foo = (a, b, b) => {};
2 | (a, b, b) => {};
3 | ((a, b, b) => {})();
: | |
: | `-- used as parameter more than once
: `-- previous definition here
: ^
4 |
5 | class Bar {
6 | constructor(a, b, b) {}
`----
x the name `b` is bound more than once in this parameter list
x Duplicate parameter name not allowed in this context: b
,-[6:1]
3 | ((a, b, b) => {})();
4 |
5 | class Bar {
6 | constructor(a, b, b) {}
: | |
: | `-- used as parameter more than once
: `-- previous definition here
: ^
7 |
8 | foo = (a, b, b) => {};
`----
x the name `b` is bound more than once in this parameter list
x Duplicate parameter name not allowed in this context: b
,-[8:1]
5 | class Bar {
6 | constructor(a, b, b) {}
7 |
8 | foo = (a, b, b) => {};
: | |
: | `-- used as parameter more than once
: `-- previous definition here
: ^
9 |
10 | bar(a, b, b) {}
11 | }
`----
x the name `b` is bound more than once in this parameter list
x Duplicate parameter name not allowed in this context: b
,-[10:1]
7 |
8 | foo = (a, b, b) => {};
9 |
10 | bar(a, b, b) {}
: | |
: | `-- used as parameter more than once
: `-- previous definition here
: ^
11 | }
12 |
13 | const baz = {
`----
x the name `b` is bound more than once in this parameter list
x Duplicate parameter name not allowed in this context: b
,-[14:1]
11 | }
12 |
13 | const baz = {
14 | foo(a, b, b) {},
: | |
: | `-- used as parameter more than once
: `-- previous definition here
: ^
15 | bar: function (a, b, b) {},
16 | };
`----
x the name `b` is bound more than once in this parameter list
,-[15:1]
12 |
13 | const baz = {
14 | foo(a, b, b) {},
15 | bar: function (a, b, b) {},
: | |
: | `-- used as parameter more than once
: `-- previous definition here
16 | };
`----
18 changes: 6 additions & 12 deletions crates/swc/tests/errors/lints/no-dupe-args/3/output.swc-stderr
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
x the name `a` is bound more than once in this parameter list
x Duplicate parameter name not allowed in this context: a
,-[1:1]
1 | function foo(a, b, [a]) {}
: | |
: | `-- used as parameter more than once
: `-- previous definition here
: ^
2 | function bar(a, b, ...a) {}
3 | function baz({ a }, b, { c: [a] }) {}
`----
x the name `a` is bound more than once in this parameter list
x Duplicate parameter name not allowed in this context: a
,-[2:1]
1 | function foo(a, b, [a]) {}
2 | function bar(a, b, ...a) {}
: | |
: | `-- used as parameter more than once
: `-- previous definition here
: ^
3 | function baz({ a }, b, { c: [a] }) {}
`----
x the name `a` is bound more than once in this parameter list
x Duplicate parameter name not allowed in this context: a
,-[3:1]
1 | function foo(a, b, [a]) {}
2 | function bar(a, b, ...a) {}
3 | function baz({ a }, b, { c: [a] }) {}
: | |
: | `-- used as parameter more than once
: `-- previous definition here
: ^
`----
18 changes: 6 additions & 12 deletions crates/swc/tests/errors/lints/no-dupe-args/4/output.swc-stderr
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
x the name `a` is bound more than once in this parameter list
x Duplicate parameter name not allowed in this context: a
,-[1:1]
1 | function foo(a, b, [a]) {
: | |
: | `-- used as parameter more than once
: `-- previous definition here
: ^
2 | function bar(c, d, ...d) {
3 | function baz({ e }, f, { f: [e] }) {}
4 | }
`----
x the name `d` is bound more than once in this parameter list
x Duplicate parameter name not allowed in this context: d
,-[2:1]
1 | function foo(a, b, [a]) {
2 | function bar(c, d, ...d) {
: | |
: | `-- used as parameter more than once
: `-- previous definition here
: ^
3 | function baz({ e }, f, { f: [e] }) {}
4 | }
5 | }
`----
x the name `e` is bound more than once in this parameter list
x Duplicate parameter name not allowed in this context: e
,-[3:1]
1 | function foo(a, b, [a]) {
2 | function bar(c, d, ...d) {
3 | function baz({ e }, f, { f: [e] }) {}
: | |
: | `-- used as parameter more than once
: `-- previous definition here
: ^
4 | }
5 | }
`----
Loading
Loading