Skip to content
New issue

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

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

Already on GitHub? # to your account

[Bug]: Destructuring unsupported iterable with array rest pattern #6302

Closed
p51lee opened this issue Nov 1, 2022 · 1 comment · Fixed by #6318
Closed

[Bug]: Destructuring unsupported iterable with array rest pattern #6302

p51lee opened this issue Nov 1, 2022 · 1 comment · Fixed by #6318
Assignees
Labels
Milestone

Comments

@p51lee
Copy link

p51lee commented Nov 1, 2022

Describe the bug

A TypeError is expected but I get ReferenceError when running the output code.

Input code

var [ ... x ] = 0 ;

Config

No response

Playground link

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

Expected behavior

0 is not iterable so the input code throws TypeError:

$ node input.js
input.js:1
var [ ... x ] = 0 ;
                ^

TypeError: 0 is not iterable
    at Object.<anonymous> (/Users/p51lee/dev/esmeta-plrg/input.js:1:17)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Node.js v18.11.0

Actual behavior

The output code throws ReferenceError:

$ node output.js
output.js:16
    return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
                                                                                             ^

ReferenceError: i is not defined
    at _toArray (/Users/p51lee/dev/esmeta-plrg/output.js:16:94)
    at Object.<anonymous> (/Users/p51lee/dev/esmeta-plrg/output.js:26:11)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Node.js v18.11.0

Version

1.3.11 (default SWC playground)

Additional context

No response

@p51lee p51lee added the C-bug label Nov 1, 2022
@kdy1 kdy1 added this to the Planned milestone Nov 1, 2022
@kdy1 kdy1 assigned kdy1 and unassigned kdy1 Nov 1, 2022
@kdy1 kdy1 closed this as completed in #6318 Nov 2, 2022
kdy1 added a commit that referenced this issue Nov 2, 2022
**Related issue (if exists):**

 - Closes #6302.
@kdy1 kdy1 modified the milestones: Planned, v1.3.13 Nov 2, 2022
@swc-bot
Copy link
Collaborator

swc-bot commented Dec 3, 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 Dec 3, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants