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

Spreading array into arrow function receives undefined arguments #8806

Closed
arshaw opened this issue Apr 3, 2024 · 1 comment · Fixed by #8809
Closed

Spreading array into arrow function receives undefined arguments #8806

arshaw opened this issue Apr 3, 2024 · 1 comment · Fixed by #8809
Assignees
Labels
Milestone

Comments

@arshaw
Copy link

arshaw commented Apr 3, 2024

Describe the bug

It seems that arrays destructuring optimizations with arrow functions are incorrect.

Input code

function logTheNine() {
  ((theThree, theNine) => {
    console.log(theNine)
  })(...[ 3, 9 ]);
}

logTheNine();

Config

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": false
    },
    "target": "es2018",
    "loose": false,
    "minify": {
      "compress": {
        "arguments": false,
        "arrows": true,
        "booleans": true,
        "booleans_as_integers": false,
        "collapse_vars": true,
        "comparisons": true,
        "computed_props": true,
        "conditionals": true,
        "dead_code": true,
        "directives": true,
        "drop_console": false,
        "drop_debugger": true,
        "evaluate": true,
        "expression": false,
        "hoist_funs": false,
        "hoist_props": true,
        "hoist_vars": false,
        "if_return": true,
        "join_vars": true,
        "keep_classnames": false,
        "keep_fargs": true,
        "keep_fnames": false,
        "keep_infinity": false,
        "loops": true,
        "negate_iife": true,
        "properties": true,
        "reduce_funcs": false,
        "reduce_vars": false,
        "side_effects": true,
        "switches": true,
        "typeofs": true,
        "unsafe": false,
        "unsafe_arrows": false,
        "unsafe_comps": false,
        "unsafe_Function": false,
        "unsafe_math": false,
        "unsafe_symbols": false,
        "unsafe_methods": false,
        "unsafe_proto": false,
        "unsafe_regexp": false,
        "unsafe_undefined": false,
        "unused": true,
        "const_to_let": true,
        "pristine_globals": true,
        "passes": 2
      },
      "mangle": false
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.4.11&code=H4sIAAAAAAAAA%2BNKK81LLsnMz1PIyU8PyUj1y8xL1dBUqOZSUNDQKMlIDckoSk3VUSiByGgq2NqB5RQUkvPzivNzUvWA2jRgskCJWk0NPT29aAVjHQVLhVhNa65aLi5kk625AHmWkb5yAAAA&config=H4sIAAAAAAAAA32US3LbMAyG9z6FR%2Bsu2iwynRygu56BQ5OgTJcPDQE61mR890CU7LgxpJ2EDz9AAiA%2Bdvt9d0LTve0%2F%2BJN%2FBl0Qyv2fLTgm0he2dGCiRlP8QN2PGz3hhJwOCM10nUlHuvRATYUvP3%2F9XhRdyBnhplhs0SfvxsecJsehAOKDja0cskZIhP%2FrF1by%2BwSo1Ef7IecAOm0QpVH5RNBDkQKbHIIeENRZFyHKdFJdPGYpxQQrgVVDyYPIk%2FXkc%2BKcz9SCtspkCwLyBQz5M0gyzsWyhHw94T4NWzjUvm99%2FqaGsw5Vk5ATLq0lfFoh6jF7JOVqkko4w5UazHAp7neld6oA1ZKedafs00pP%2FgFwBYJGTDqCFLd5OJ6nNbXbVPrkeGRpFDjPt3TLBD0XVXnvhMpOlYFCXupmAVsNTJU10nEWvFI%2B9BYUOMezIoTGd0%2FmKCWlcYDsBMD91U6aqhmo%2Bytc4dOD2MB%2F%2BJYkD9jiETUd1ymO8ZDDRoIIdMx2w4FbQXkdF94Sl2Gd12SBRwOs6FKxgeclwA%2BAsgptXz7NBj8Pjqj6kA%2Fimhh4zlsTXxbb9b6co0791xKY9%2FNucehitrXBZfNPTZ%2F39Wv35XRbzffbdB7%2F3pTTSXbXTzRLP3hFBgAA

SWC Info output

console.log(void 0);

Expected behavior

console.log(9);

Actual behavior

console.log(void 0);

Version

1.4.11

Additional context

Original issue: fullcalendar/temporal-polyfill#36

@arshaw arshaw added the C-bug label Apr 3, 2024
@kdy1 kdy1 added this to the Planned milestone Apr 3, 2024
@kdy1 kdy1 self-assigned this Apr 3, 2024
@kdy1 kdy1 closed this as completed in #8809 Apr 4, 2024
kdy1 added a commit that referenced this issue Apr 4, 2024
@kdy1 kdy1 modified the milestones: Planned, v1.4.12 Apr 4, 2024
@swc-bot
Copy link
Collaborator

swc-bot commented May 4, 2024

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 May 4, 2024
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