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

Thread '<unnamed>' panicked at 'called Option::unwrap() on a None value' #2821

Closed
clhiker opened this issue Nov 21, 2021 · 1 comment · Fixed by #2866
Closed

Thread '<unnamed>' panicked at 'called Option::unwrap() on a None value' #2821

clhiker opened this issue Nov 21, 2021 · 1 comment · Fixed by #2866
Labels
Milestone

Comments

@clhiker
Copy link

clhiker commented Nov 21, 2021

Describe the bug

When I run the swc, I get a serious error from swc

thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', ecmascript/transforms/compat/src/es2015/destructuring.rs:181:42
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failed to handle: called `Option::unwrap()` on a `None` value
Error: Failed to compile 1 file with swc.
    at Object.assertCompilationResult (/D/N2ttFuzz/src/node_modules/@swc/cli/lib/swc/util.js:115:15)
    at files (/D/N2ttFuzz/src/node_modules/@swc/cli/lib/swc/file.js:175:18)
    at async _default (/D/N2ttFuzz/src/node_modules/@swc/cli/lib/swc/file.js:194:9)

Input code

const [x, y, ...z] = [1];

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.111&code=H4sIAAAAAAAAA0vOzysuUYiu0FGo1FHQ09OrilWwVYg2jLUGAP75xrgZAAAA&config=H4sIAAAAAAAAA0VOOw6DMAy9i2fWLtygA4ewgkFBSRzZRmqKuHsTNcBkv4%2Ff8wGbOhgPyChK0jYtyfADI5CLqE58NhiqrVILBqVzAENZyZpFX1ULzEpdHSD65JfSkhzHLKT6SJjWcDnPGhR53htxgJVcZzuJnDatqWrind23fzjx%2FDQF%2FJYbJH4nI%2BH8vHl90h1ep15nstP5A1SlDpf7AAAA

Expected behavior

It's the expected transform

var _ref = [1],
    x = _ref[0],
    y = _ref[1],
    z = _ref.slice(2);

Version

1.2.111

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 21, 2021
@kdy1 kdy1 modified the milestones: v1.2.112, v1.2.113 Nov 21, 2021
kdy1 pushed a commit that referenced this issue Nov 25, 2021
swc_ecma_transforms_compat:
 - Check length correctly. (Closes #2819, Closes #2821, Closes #2843)
@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