-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Minifier should check type of assignment target before merging assignments #8718
Comments
@kdy1 🤔 Since it's non-trivial to track the changes of types of vars, it seems impossible to do the check. |
@CPunisher Does this still happen? I made similar conclusion and I disabled such operations with #9575 |
@CPunisher, are you also on SWC Discord? I have a question for you, but I want to ask it privately. |
Yes, it still happens. This bug is caused by not considering the type of the var, while that pr considers the types of right operands in the assignment sequence. Edit by maintainers: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks! |
I'm under the impression that we should disable optimization of |
Let's discuss everything here.
No, it's not enough. I realize that the usage analyzer is flow-insensitive, so it's hard to know the accurate type of a variable and I get stuck.
But is it possible to know whether the operand has an unknown type? |
Yeap, there's a |
So in this case: let a = 0;
// a = ""; Maybe it changes
console.log((a += 1, a += 2)) The only thing we know about |
In the sequential optimizer |
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
Currently in
replace_seq_assignment
step, we don't check the type of target.however, if the type of target differs, the total count of actual operations matters.
Input code
Config
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.4.6&code=H4sIAAAAAAAAA8tJLVFIVLBVUFe35krOzyvOz0nVy8lP19BIVNC2VTDUUQDTRpqaAAJDHUQpAAAA&config=H4sIAAAAAAAAA32UO5LbMAyGe5%2FCozpF4iJFDrBdzsChSVCmlw8NAXqt2fHdA1Gy11lD6iR8%2BAESAPG52%2B%2B7M5ruz%2F6TP%2Fln0AWhPP7ZgmMifWVLByZqNMUP1P240zNOyOmA0Ey3mXSkSw%2FUVHj4eTgsii7kjHBXLLbok3fjc06T41AA8cnGVg5ZIyTC%2F%2FULK%2FljAlTqs%2F2YcwCdNojSqHwi6KFIgU0OQQ8I6qKLEGU6qS4es5RigpXAqqHkQeTJevI5cc5XakFbZbIFAfkChvwFJBnnYllCvp5wn4YtHGvftz5%2FU8NFh6pJyAnX1hI%2BrRD1lD2ScjVJJZzhSg1muBT3u9I7VYBqSa%2B6c%2FZppSfvAFyBoBGTjiDFbR6O52lN7TaVPjkeWRoFzvMt3TJBz0VV3juhslNloJCXulnAVgNTZY10nAWvlA%2B9BQXO8awIofHDkzlJSWkcIDsBcH%2B1k6ZqBurxClf49CA28BvfkuQBWzyiptM6xTEec9hIEIFO2W44cCsor%2BPCW%2BI6rPOaLPBogBVdKjbwugT4AVBWoe3Ll9ng58ERVR%2FyUVwTA895a%2BKvxXZ7LOeoU%2F%2B1BOb9vFscuphtbXDZ%2FFPT5339u%2Ftyuq%2Fmx206j3%2Fvyukku9s%2FdoKzJEUGAAA%3D
SWC Info output
No response
Expected behavior
or don't minify it
Actual behavior
which results '3'
Version
1.4.6
Additional context
No response
The text was updated successfully, but these errors were encountered: