tools icon indicating copy to clipboard operation
tools copied to clipboard

🐛 Semantics: Incorrect redeclaration error for parameters of arrow function expressions

Open Boshen opened this issue 3 years ago • 6 comments
trafficstars

Environment information

Playground

This is found inside material-ui.

What happened?

const {
  a = (arg) => {},
  b = (arg) => {},
} = props;

errored with

error[SyntaxError]: Declarations inside of a `const` declaration may not have duplicates
  ┌─ main.js:3:8
  │
2 │   a = (arg) => {},
  │        --- `arg` is first declared here
3 │   b = (arg) => {},
  │        ^^^ a second declaration of `arg` is not allowed

Expected result

No error.

Code of Conduct

  • [X] I agree to follow Rome's Code of Conduct

Boshen avatar Jul 29 '22 05:07 Boshen

Found another case in react-admin

error[SyntaxError]: Declarations inside of a `const` declaration may not have duplicates
   ┌─ react-admin/packages/ra-ui-materialui/src/layout/Menu.tsx:54:22
   │
53 │                 .filter(name => resources[name].hasList)
   │                         ---- `name` is first declared here
54 │                 .map(name => (
   │                      ^^^^ a second declaration of `name` is not allowed

Boshen avatar Jul 29 '22 06:07 Boshen

Yeah, moving this to the analyzer is a good idea, now that @xunilrj implemented the semantic model.

One thing that we may need to do tough is to change the t262 tests to no longer run against the parser only but run with analyze.

@xunilrj is this something you might be interested in looking at? There are probably more checks that we could move from our parser into the analyzer.

MichaReiser avatar Jul 29 '22 15:07 MichaReiser

There are a couple of other changes I want to move from the parser to linters. I will create a small list and we can decide if makes sense or not.

xunilrj avatar Aug 03 '22 06:08 xunilrj

This issue is stale because it has been open 14 days with no activity.

github-actions[bot] avatar Sep 08 '22 12:09 github-actions[bot]

Going to re-open: @xunilrj are there any progress around this issue? Should we close it?

ematipico avatar Sep 15 '22 12:09 ematipico

This issue is stale because it has been open 14 days with no activity.

github-actions[bot] avatar Oct 03 '22 12:10 github-actions[bot]