Fixed `SyntaxError` when obfuscating a class that extends a boolean literal by cycsmail · Pull Request #1420 · javascript-obfuscator/javascript-obfuscator · GitHub
Skip to content

Fixed SyntaxError when obfuscating a class that extends a boolean literal#1420

Open
cycsmail wants to merge 1 commit into
javascript-obfuscator:masterfrom
cycsmail:fix/boolean-literal-extends-syntax-error
Open

Fixed SyntaxError when obfuscating a class that extends a boolean literal#1420
cycsmail wants to merge 1 commit into
javascript-obfuscator:masterfrom
cycsmail:fix/boolean-literal-extends-syntax-error

Conversation

@cycsmail

Copy link
Copy Markdown

class C extends true {} is valid JavaScript, but BooleanLiteralTransformer rewrote true/false into !![]/![] even in the extends position, emitting class C extends ![] {}. A class heritage must be a LeftHandSideExpression, so that causes an early SyntaxError. I skip the transformation when the literal is the class superClass and leave it unchanged; booleans everywhere else are still transformed as before. Added a regression test (it fails without the fix and passes with it).

Fixes #1131

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.

[Bug] Extending a boolean literal results in SyntaxError

1 participant