Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destructure a Non-Iterable Instance #2863

Closed
clhiker opened this issue Nov 24, 2021 · 1 comment · Fixed by #2904
Closed

Destructure a Non-Iterable Instance #2863

clhiker opened this issue Nov 24, 2021 · 1 comment · Fixed by #2904
Labels
Milestone

Comments

@clhiker
Copy link

clhiker commented Nov 24, 2021

Describe the bug

A non-iterable instance is destructure correctly by swc. It is grammatically wrong.

Input code

// poc_01
[a] = 0;
// poc_02
[,,]=0

Config

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": false,
      "dynamicImport": false,
      "privateMethod": false,
      "functionBind": false,
      "exportDefaultFrom": false,
      "exportNamespaceFrom": false,
      "decorators": false,
      "decoratorsBeforeExport": false,
      "topLevelAwait": false,
      "importMeta": false
    },
    "transform": null,
    "target": "es5",
    "loose": false,
    "externalHelpers": false
  }
}

Playground link

https://play.swc.rs/?version=1.2.112&code=H4sIAAAAAAAAA4tOjFWwVTCw5orW0Ym1NQAAuZl3ng8AAAA%3D&config=H4sIAAAAAAAAA0WMTQrEIAxG75K1286id5hDBCctFv9IUhgR714tlu7C915ehUMsrBUyshCPS0pU%2FMMKZAOKZZcVTNf6tKEXagYUeScdiiyd%2BZSEJjUQXHRbGSWbQmYSeRHG3T9m66GQfucYKmjJdAc%2F0N7G%2FHPynaLySe0Cj9ke9LUAAAA%3D

Expected behavior

There should be a syntax error like this:

cannot read property Symbol(Symbol.iterator)).

or

Invalid attempt to destructure non-iterable instance.

Instead of running correctly after being converted》

Version

1.2.112

Additional context

I run swc use cmd as follows

npx swc --config-file=.swcrc poc.js -o poc.js

The environment is ubuntu 20.04 amd64.

@clhiker clhiker added the C-bug label Nov 24, 2021
@kdy1 kdy1 modified the milestones: v1.2.113, v1.2.114, v1.2.115 Nov 24, 2021
kdy1 pushed a commit that referenced this issue Nov 30, 2021
swc_ecma_transforms_compat:
 - `desturcturing`: Fix non-loose mode. (Closes #2841, Closes #2863)
dsherret pushed a commit to dsherret/swc that referenced this issue Nov 30, 2021
swc_ecma_transforms_compat:
 - `desturcturing`: Fix non-loose mode. (Closes swc-project#2841, Closes swc-project#2863)
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 20, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants