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

Incorrect compressor behavior in switch #9628

Closed
bin1357 opened this issue Oct 8, 2024 · 1 comment · Fixed by #9633
Closed

Incorrect compressor behavior in switch #9628

bin1357 opened this issue Oct 8, 2024 · 1 comment · Fixed by #9633
Assignees
Labels
Milestone

Comments

@bin1357
Copy link

bin1357 commented Oct 8, 2024

Describe the bug

See example

Input code

const getString = () => {
  switch ("apple") {
    case 'apple':
      return '1';
    case 'banana':
      return '2';
  }
  return "3"
};


console.log(getString());

Config

{
 "jsc": {
  "parser": {
   "syntax": "ecmascript",
  },
  "target": "es5",
  "minify": {
    "mangle": false,
    "compress": true,
  }
 },
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.7.28&code=H4sIAAAAAAAAA0vOzysuUUhPLQkuKcrMS1ewVdDQVLC1U6jm5VJQKC7PLEnOUNBQSiwoyElV0oSIKigkJxanKqiDBdWtIEIKCkWpJaVFeQrqhurWyKqSEvOAEFOZEURZLYiAiikZK%2FFy1QKFQTAZ6LD8nFS9nPx0DbjzNDQ1rQEoac67sgAAAA%3D%3D&config=H4sIAAAAAAAAAzWMQQqFMAwF9z1FyNqtG28TSpSKrSWJoEjvbqz%2Fbx7MDLw7AK4acYI7AGAlUZYfAepVjE5H5JhJo6RqOHhq76CRLGw969g95lTSfP0PnKksGzvPtCkPn4x7rsKqrk2Oblt4P9sDpwS%2Bn48AAAA%3D

SWC Info output

No response

Expected behavior

console.log('1');

Actual behavior

console.log('3');

Version

1.7.28

Additional context

No response

@bin1357 bin1357 added the C-bug label Oct 8, 2024
@bin1357
Copy link
Author

bin1357 commented Oct 9, 2024

Surprisingly, disabling the dead_code option in the compressor corrects the situation...

@kdy1 kdy1 added this to the Planned milestone Oct 9, 2024
@Austaras Austaras self-assigned this Oct 11, 2024
@kdy1 kdy1 closed this as completed in 6f52949 Oct 12, 2024
@kdy1 kdy1 modified the milestones: Planned, v1.7.36 Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

3 participants