trullock / NUglify

NUglify is a HTML, JavaScript and CSS minification Library for .NET (fork of AjaxMin + new features)
Other
398 stars 79 forks source link

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

Open limsbeheer opened 1 year ago

limsbeheer commented 1 year ago

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 commented 1 year ago

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

You can easily change this, make a PR