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

panic: async function #1477

Closed
mirek opened this issue Mar 18, 2021 · 3 comments · Fixed by #1529
Closed

panic: async function #1477

mirek opened this issue Mar 18, 2021 · 3 comments · Fixed by #1529
Assignees
Labels
Milestone

Comments

@mirek
Copy link

mirek commented Mar 18, 2021

  1. Source code
async function f(a, b) {
  const [ { a: a_ = 1 } ] = JSON.parse(b)
}

or:

npx swc --no-swcrc << 'END'
async function f(a, b) {
  const [ { a: a_ = 1 } ] = JSON.parse(b)
}
END
  1. .swcrc file
    --no-swcrc

  2. Error message

npx swc --no-swcrc --sync swc-bug.ts
thread '<unnamed>' panicked at 'not implemented: assignment pattern AssignPat { span: Span { lo: BytePos(40), hi: BytePos(46), ctxt: #0 }, left: Ident(BindingIdent { id: Ident { span: Span { lo: BytePos(40), hi: BytePos(42), ctxt: #2 }, sym: Atom('a_' type=inline), optional: false }, type_ann: None }), right: Lit(Num(Number { span: Span { lo: BytePos(45), hi: BytePos(46), ctxt: #0 }, value: 1.0 })), type_ann: None }', ecmascript/transforms/compat/src/es2015/destructuring.rs:810:41
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
not implemented: assignment pattern AssignPat { span: Span { lo: BytePos(40), hi: BytePos(46), ctxt: #0 }, left: Ident(BindingIdent { id: Ident { span: Span { lo: BytePos(40), hi: BytePos(42), ctxt: #2 }, sym: Atom('a_' type=inline), optional: false }, type_ann: None }), right: Lit(Num(Number { span: Span { lo: BytePos(45), hi: BytePos(46), ctxt: #0 }, value: 1.0 })), type_ann: None }
Error: Failed to compile 1 file with swc.
    at Object.assertCompilationResult (/Users/mirek/.../node_modules/@swc/cli/lib/swc/util.js:152:15)
    at files (/Users/mirek/.../node_modules/@swc/cli/lib/swc/file.js:176:18)
  1. Backtrace
SWC_DEBUG=1 npx swc --no-swcrc --sync swc-bug.ts
Backtrace:    0: _napi_register_module_v1
   1: <unknown>
   2: _rust_eh_personality
   3: _rust_eh_personality
   4: _rust_eh_personality
   5: _rust_eh_personality
   6: _rust_eh_personality
   7: _rust_eh_personality
   8: _rust_eh_personality
   9: _rust_eh_personality
  10: _rust_eh_personality
  11: _rust_eh_personality
  12: _rust_eh_personality
  13: _rust_eh_personality
  14: _rust_eh_personality
  15: _rust_eh_personality
  16: _rust_eh_personality
  17: _rust_eh_personality
  18: _rust_eh_personality
  19: _rust_eh_personality
  20: _rust_eh_personality
  21: _rust_eh_personality
  22: _rust_eh_personality
  23: _rust_eh_personality
  24: _rust_eh_personality
  25: _rust_eh_personality
  26: _rust_eh_personality
  27: _rust_eh_personality
  28: _rust_eh_personality
  29: _rust_eh_personality
  30: _rust_eh_personality
  31: _rust_eh_personality
  32: _rust_eh_personality
  33: _rust_eh_personality
  34: _rust_eh_personality
  35: _rust_eh_personality
  36: _rust_eh_personality
  37: <unknown>
  38: __ZN6v8impl12_GLOBAL__N_123FunctionCallbackWrapper6InvokeERKN2v820FunctionCallbackInfoINS2_5ValueEEE
  39: __ZN2v88internal25FunctionCallbackArguments4CallENS0_15CallHandlerInfoE
  40: __ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEESA_NS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EENS0_16BuiltinArgumentsE
  41: __ZN2v88internalL26Builtin_Impl_HandleApiCallENS0_16BuiltinArgumentsEPNS0_7IsolateE

not implemented: assignment pattern AssignPat { span: Span { lo: BytePos(40), hi: BytePos(46), ctxt: #0 }, left: Ident(BindingIdent { id: Ident { span: Span { lo: BytePos(40), hi: BytePos(42), ctxt: #2 }, sym: Atom('a_' type=inline), optional: false }, type_ann: None }), right: Lit(Num(Number { span: Span { lo: BytePos(45), hi: BytePos(46), ctxt: #0 }, value: 1.0 })), type_ann: None }
Error: Failed to compile 1 file with swc.
    at Object.assertCompilationResult (/Users/mirek/.../node_modules/@swc/cli/lib/swc/util.js:152:15)
    at files (/Users/mirek/ab/.../@swc/cli/lib/swc/file.js:176:18)
@mirek mirek added the C-bug label Mar 18, 2021
@mirek
Copy link
Author

mirek commented Mar 18, 2021

Btw. dropping async from function seems to work just fine.

@mirek
Copy link
Author

mirek commented Mar 18, 2021

      function f(a, b) { const { a: a_ = 1 } = b } // OK
async function f(a, b) { const { a: a_ = 1 } = b } // PANIC
async function f(a, b) { const { a: a_     } = b } // OK
async function f(a, b) { const { a     = 1 } = b } // OK

@kdy1 kdy1 added this to the v1.2.52 milestone Mar 28, 2021
@kdy1 kdy1 self-assigned this Apr 1, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Apr 1, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Apr 1, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Apr 1, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Apr 1, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Apr 1, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Apr 1, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Apr 1, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Apr 1, 2021
@kdy1 kdy1 mentioned this issue Apr 1, 2021
4 tasks
@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