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 sparse array with rest #6325

Open
p51lee opened this issue Nov 2, 2022 · 0 comments
Open

[Bug]: Destructuring sparse array with rest #6325

p51lee opened this issue Nov 2, 2022 · 0 comments
Labels

Comments

@p51lee
Copy link

p51lee commented Nov 2, 2022

Describe the bug

x is expected to be an array of length 1 that contains undefined but it is an array with an empty item.
Babel also had this bug so I have submitted a similar issue to babel: babel/babel#14983

Input code

let [ ... x ] = [ , ] ;

Config

No response

Playground link

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

Expected behavior

x is expected to be an array of length 1 that contains undefined :

$ node input.js
[ undefined ]

Actual behavior

x is an array with an empty item:

$ node output.js
[ <1 empty item> ]

Version

1.3.11 (default SWC playground)

Additional context

No response

@p51lee p51lee added the C-bug label Nov 2, 2022
@kdy1 kdy1 added this to the Planned milestone Nov 2, 2022
@kdy1 kdy1 self-assigned this Nov 3, 2022
@kdy1 kdy1 removed their assignment Nov 24, 2022
@kdy1 kdy1 removed this from the Planned milestone Jan 17, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants