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

Missing parenthesis in await (.. || ..) #2155

Closed
mischnic opened this issue Aug 25, 2021 · 1 comment · Fixed by #2157
Closed

Missing parenthesis in await (.. || ..) #2155

mischnic opened this issue Aug 25, 2021 · 1 comment · Fixed by #2157
Labels
Milestone

Comments

@mischnic
Copy link
Contributor

Describe the bug

The codegen should emit parenthesis when awaiting a binary expression

Input code

index.js:

main();
async function main() {
    let promise;
    await (promise || (promise = Promise.resolve("this is a string")));
}

Config

.swcrc

{
	"env": {}
}
{
  "devDependencies": {
    "@swc/cli": "0.1.49",
    "@swc/core": "1.2.82"
  },
  "browserslist": "Chrome 80",
  "scripts": {
    "build": "swc index.js -o dist/swc.js"
  }
}

Expected behavior
It should still be await (.. || ..), so the output should be the same as the input

Current behavior

main();
async function main() {
    let promise;
    await promise || (promise = Promise.resolve("this is a string"));
}

Version
The version of @swc/core: 1.2.82

Additional context
parcel-bundler/parcel#6765
cc @danieltroger

@mischnic mischnic added the C-bug label Aug 25, 2021
@kdy1 kdy1 added this to the v1.2.83 milestone Aug 26, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Aug 26, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Aug 26, 2021
kdy1 added a commit that referenced this issue Aug 26, 2021
swc_ecma_transforms_base:
 - Preserve parenthesis in `await (a || b)`. (#2155)
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 22, 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 22, 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