Skip to content

Exponentiation operator#407

Merged
michaelficarra merged 3 commits intoestools:masterfrom
javascript-obfuscator:exponentiation-operator
Feb 5, 2020
Merged

Exponentiation operator#407
michaelficarra merged 3 commits intoestools:masterfrom
javascript-obfuscator:exponentiation-operator

Conversation

@sanex3339
Copy link
Copy Markdown
Contributor

@sanex3339 sanex3339 commented Jan 29, 2020

@sanex3339
Copy link
Copy Markdown
Contributor Author

@michaelficarra I will be happy if you will review it

@pawelzwronek
Copy link
Copy Markdown

It would be great to include this PR in next release.

@michaelficarra
Copy link
Copy Markdown
Member

michaelficarra commented Jan 29, 2020

I would like to see tests for forced grouping of unary operations on the LHS. For example, we shouldn't render (-1) ** 0 as -1 ** 0. At the same time, we should render 0 ** (-1) as 0 ** -1.

@sanex3339
Copy link
Copy Markdown
Contributor Author

But currently in master it rendered (-1) * 0 as -1 * 0

@michaelficarra
Copy link
Copy Markdown
Member

michaelficarra commented Jan 29, 2020

@sanex3339 the * and ** operators have different grammars. the LHS of ** is a higher precedence position than the RHS.

@sanex3339
Copy link
Copy Markdown
Contributor Author

Hmm. Will try to fix

@sanex3339
Copy link
Copy Markdown
Contributor Author

@michaelficarra I have no idea what i'm doing, but looks like now new test cases for LHS expression are passing

@michaelficarra michaelficarra force-pushed the exponentiation-operator branch from a01fc97 to 35e7739 Compare February 5, 2020 17:57
@michaelficarra
Copy link
Copy Markdown
Member

@sanex3339 I pushed up another commit. Please review.

@sanex3339
Copy link
Copy Markdown
Contributor Author

@michaelficarra Looks good, thank you!

@michaelficarra michaelficarra merged commit a25d531 into estools:master Feb 5, 2020
@michaelficarra
Copy link
Copy Markdown
Member

michaelficarra commented Feb 6, 2020

@sanex3339 Published version 1.14.0.

edit: Pushed a 1.14.1 since I noticed unnecessary parentheses on the LHS. Added a regression test so it doesn't happen again.

bizob2828 pushed a commit to Contrast-Security-OSS/escodegen that referenced this pull request Apr 2, 2020
* Fixed exponentiation operator precedence

* Fixed and added test cases for LHS expression of exponentiation operator

* fix exponentiation PR

Co-authored-by: Michael Ficarra <github@michael.ficarra.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong parenthesis with exponentiation operator Removed brackets when ** operator is used

3 participants