Skip to content

Exponential operator in if condition is not transpiled #2821

Closed
@teppeis

Description

@teppeis

Original source code:

if (2 ** 3 > 0) { alert('test'); }

Expected transpiled code:

0 < Math.pow(2, 3) && alert("test");

Actual result

0 < 2 ** 3 && alert("test");

Same result in ternary operator.


Also, it throws an error in Advanced Optimization.

JSC_INTERNAL_ERROR_UNEXPECTED_TOKEN: Internal Error: TypeCheck doesn't know how to handle EXPONENT at line 1 character 4
if (2 ** 3 > 0) { alert('test'); }
    ^

If another exponential operator is in body, they are transpiled.
Original:

if (2 ** 3 > 0) { alert(2 ** 3); }

Transpiled:

0 < Math.pow(2, 3) && alert(Math.pow(2, 3));

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions