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

minifier: invalid parenthesizing when inlining switch statement with case clause expression contains optional chaining #8844

Closed
hyp3rflow opened this issue Apr 11, 2024 · 1 comment · Fixed by #8850
Assignees
Labels
Milestone

Comments

@hyp3rflow
Copy link
Sponsor Contributor

hyp3rflow commented Apr 11, 2024

Describe the bug

Invalid parenthesizing makes expression invalid after compression.

Input code

const k = (() => {
  let x;
  switch (x) {
    case x?.x?.():
    default:
  }
})();

Config

No response

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.4.13&code=H4sIAAAAAAAAA0vOzysuUchWsFXQ0NBUsLVTqOZSUMhJLVGosAYyisszS5IzFDQqNMHiCgrJicWpChX2ekCkoWkFFkpJTUsszSkBcWq5ajU1NK0Bkqo9h1QAAAA%3D&config=H4sIAAAAAAAAA32UO3LjMAyG%2B5zCozrFjostcoDtcgYOLYIyvSShIUDHmozvvtDDj40hdRI%2B%2FAAJgPh%2B2%2B2aE7XNx%2B5bPuWnt4Wg3P%2FFQkNmexFLA22y1JbQc%2FN%2BoycakbeRYDJdZ9KwLR3wpKL9r%2F1%2BUTQRkeCmWGwp5OCH55wtpr4A0ZNNrBKyJshM%2F%2BsXVvBrBFzqs%2F2AGMHmDWIsmZAZOiha4BZjtD2BOduiRBlPaksg1FKMsDI40xfsVZ5d4IBZcr5SB9aZFh0oKBRoOZxBk0kukWWS6yn3mbCDQ%2B26qc8%2F1HC2sVpWcsJlaomcVol6xEBsfM1aCWe4UoMZLsX9qQzeFOBa8qvuhCGv9OQvgFQgWqJsE2hxJw8v87Sm9pvKkL2MLA8Kl%2FnWbpmhk6KaELxS2bEyUDho3SzgagtjZVvtOAteKR8FBwa8l1lRQtNX4PaoJeWhB%2FQKkP5ar03VDMz9Fa7w8UFs4D9yS9YHbPFIlo%2FrlIZ0wLiRIAEf0W04SCsY13GRLXHp13nNDmQ0wKkulSbwugTkATCaOO3Ll9mQ5yERTRfx8FgTi8P1voeTzd3jvc%2Br%2BG1xaBK6OsFlyY%2F9nVfz7%2BbhdNvC94M3gT5vyjns9R%2F7ntJqMQYAAA%3D%3D

SWC Info output

No response

Expected behavior

let k = (()=>{
    let x;
    x?.x?.();
})();

or

let k = (()=>{
})();

Actual behavior

let k = (()=>{
    let x;
    (x?.x)();
})();

results in function call with undefined caller. (undefined is not a function Error occurred.)

Version

1.4.13

Additional context

No response

@kdy1 kdy1 self-assigned this Apr 11, 2024
@kdy1 kdy1 added this to the Planned milestone Apr 11, 2024
kdy1 pushed a commit that referenced this issue Apr 12, 2024
@kdy1 kdy1 modified the milestones: Planned, 1.4.14 Apr 15, 2024
@swc-bot
Copy link
Collaborator

swc-bot commented May 15, 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 15, 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