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

Cannot transform nested object destructuring with default value #1449

Closed
cspotcode opened this issue Mar 2, 2021 · 2 comments · Fixed by #1529
Closed

Cannot transform nested object destructuring with default value #1449

cspotcode opened this issue Mar 2, 2021 · 2 comments · Fixed by #1529
Assignees
Labels
Milestone

Comments

@cspotcode
Copy link
Contributor

Describe the bug

Panics parsing the following destructuring assignment with default value within an async function.

When compiling the code example using the following swc CLI invocation, I get this error:

❯ ./node_modules/.bin/swc -d ./swc-out ./foo.js
thread '<unnamed>' panicked at 'not implemented: assignment pattern AssignPat { span: Span { lo: BytePos(48), hi: BytePos(55), ctxt: #0 }, left: Object(ObjectPat { span: Span { lo: BytePos(48), hi: BytePos(50), ctxt: #0 }, props: [], optional: false, type_ann: None }), right: Object(ObjectLit { span: Span { lo: BytePos(53), hi: BytePos(55), ctxt: #0 }, props: [] }), type_ann: None }', ecmascript/transforms/compat/src/es2015/destructuring.rs:810:41
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
[1]    13076 abort      ./node_modules/.bin/swc -d ./swc-out ./foo.js

Input code

This is the most minimal reproduction I could create. It appears to only happen within an async function, when the destructuring is nested, and when the nested destructured object is given a default value.

async function foo() {
    const {
        bar: {} = {}
    } = baz;
}

Config

Do not have an .swcrc

Expected behavior

The above code should compile correctly.

Version
The version of @swc/core: 1.2.49

Additional context

@cspotcode cspotcode added the C-bug label Mar 2, 2021
@kdy1 kdy1 added this to the v1.2.50 milestone Mar 3, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Mar 3, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Mar 3, 2021
@kdy1 kdy1 changed the title Cannot parse nested object destructuring with default value within async function Cannot transform nested object destructuring with default value within async function Mar 3, 2021
@kdy1 kdy1 changed the title Cannot transform nested object destructuring with default value within async function Cannot transform nested object destructuring with default value Mar 3, 2021
@kdy1
Copy link
Member

kdy1 commented Mar 3, 2021

Postponing as it a not a parsing issue.

@kdy1 kdy1 modified the milestones: v1.2.50, v1.2.51 Mar 3, 2021
@kdy1 kdy1 modified the milestones: v1.2.51, v1.2.52 Mar 28, 2021
@kdy1 kdy1 self-assigned this Apr 1, 2021
@kdy1 kdy1 mentioned this issue Apr 1, 2021
4 tasks
kdy1 added a commit to kdy1/swc that referenced this issue Apr 1, 2021
@kdy1 kdy1 closed this as completed in #1529 Apr 2, 2021
kdy1 added a commit that referenced this issue Apr 2, 2021
swc_ecma_parser:
 - Fix comment positions. (#1530)

swc_ecam_transforms_compat:
 - Handle default in destructuring binding patterns. (#1477, #1449)
 - `async_to_generator`: Handle `this` correctly for async function in key-value properties. (#1455)

swc_ecam_transforms_typescript:
 - Handle import defaults. (#1448)
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 25, 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 25, 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