You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SWC with "compress" option transpiles some expressions involving assignment, increment/decrement operator and template literal into invalid JS for ES2015+ targets. The occurrence of this issue appears to have started since v1.3.27.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Describe the bug
SWC with
"compress"
option transpiles some expressions involving assignment, increment/decrement operator and template literal into invalid JS forES2015+
targets. The occurrence of this issue appears to have started sincev1.3.27
.Input code
Config
Playground link
https://play.swc.rs/?version=1.3.70&code=H4sIAAAAAAAAA8tJLVHITFGwVTCw5uJKK81LLsnMz1NITy3xTNHQVKjmUgACsDyQUFWwBAJrsFhRaklpUZ5Cgkp1Zoq2dm0CVy0AFqXyMEoAAAA%3D&config=H4sIAAAAAAAAA32UwW7bMAyG732KwOcdtgLdYQ%2Bw255BUCTKUSaLhkilMYq8%2B2jZSbOGzs3mx5%2BUSIofL7tddyTX%2Fdp9yKf8jLYQlNu%2FWGjKbM9i6cANllyJI3ffrvRIMwo2ETTTZSEd29IDNxW9fv%2Fxtiq6hEhwVay2IeYYpvucDoexANGdTawSsg6Qmf7Xr6zg%2Bwy41Hv7HjGBzU%2BIsWRiZuihaIEdpmRHAnOyRYkyn9SWSKilmGFl8GYsOKo8%2B8gRs%2BR8pB6sNw49KCgWcBxPoMkkl8gyyfWU%2BzTsYV%2F7vvX5ixpONlXLSk44t5bIaR%2FZASOxCTVrFVzgRgkWuNb2qzIGU4BrUTIeMeaNlvwFkAIkS5TtAFrc5hFknLbU4aky5iATy5PCZby1W2bopaYmxqAUdq4MFI5aMwv46mCurNOOs%2BKN8lH0YCAEGRUlNL1HdgctKU8jYFCA9NcGbagWYG6PcIPP7%2BEJ%2Fi235GW%2BNjwGy4dtStOwx%2FQkwQB8QP%2FEQVrBuI2LLInzuM1r9iCjAV51qdTA4w6QB8BoUluXD7Mhz0Mimj7hXt0So8x5a%2BLrarvcdvNgc%2F%2B5A5b1%2FLI6dAP62uC6%2BOemL%2Bv6Z%2FfpdN3Mt9t0kf5clUvYyz%2FC6tcBRQYAAA%3D%3D
Expected behavior
Transpilation to ES5 returns syntactically correct Javascript
resembling, for instance, Terser with ecma2015 target
Actual behavior
It tries to combine compound assignment with increment operator in one expression inside template string:
Version
1.3.70
Additional context
The example above can be reduced to something like:
which is transpiled into:
where
10++
leads to an errorUncaught SyntaxError: Invalid left-hand side expression in postfix operation
The text was updated successfully, but these errors were encountered: