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

SyntaxError: Unexpected token '??'. Coalescing and logical operators used together in the same expression; parentheses must be used to disambiguate. #834

Closed
wagenet opened this issue Sep 23, 2020 · 3 comments
Labels

Comments

@wagenet
Copy link

wagenet commented Sep 23, 2020

Bug report or Feature request?

Bug Report

Version (complete output of terser -V or specific git commit)

5.3.1

Complete CLI command or minify() options used

Run via ember-cli-terser.

terser input

return (this.span?.durationSelf && this.span.durationSelf / 1000) ?? null;

terser output or error

return this.span?.durationSelf&&this.span.durationSelf/1e3??null

Causes this error in browser:

SyntaxError: Unexpected token '??'. Coalescing and logical operators used together in the same expression; parentheses must be used to disambiguate.

Expected result

I believe it would work if the following was generated:

return (this.span?.durationSelf&&this.span.durationSelf/1e3)??null
@fabiosantoscode
Copy link
Collaborator

Thanks for reporting!

@chrisvdp
Copy link

We also experienced this issue.

@fabiosantoscode
Copy link
Collaborator

The fix was relatively simple. I had to look at the spec for a bit and realized that the precedence rules are weirder than I originally thought :)

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

No branches or pull requests

3 participants