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

When using ?? in combination with || the necessary parentheses are removed #368

Open
limsbeheer opened this issue Sep 26, 2023 · 1 comment

Comments

@limsbeheer
Copy link

NUglify version: 1.20.7
Reproduced in tiny console app in .NET 7.0

Describe the bug
When using ?? in combination with || the necessary parentheses are removed in the minified code.

To Reproduce
Uglify.Js("if ((a ?? b ?? c) || await d()) {}");

Minified output or stack trace
Output code: a??b??c||await d() which results in the JavaScript exception Uncaught SyntaxError: Unexpected token '||'.

Expected output code
(a??b??c)||await d()
The parentheses around a??b??c cannot be removed.

@trullock
Copy link
Owner

It's probably treating the operator precedence for ?? the same as ||.

You can easily change this, make a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants