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
If normal, 'result' should appear when the logic below is executed.
bug().then(alert)
However, minify with swc, the error below occurs.
Uncaught TypeError: Cannot read properties of undefined (reading 'resolve')
This is because the logic in the try statement changes to 'break' and window.current is immediately deleted in finally.
The problem is reproduced even when only the if_return option of compressor is enabled.
This problem does not occur with terser.
Input code
functionDeferred(){constdeferred=this;deferred.promise=newPromise(function(resolve,reject){deferred.resolve=resolve;deferred.reject=reject;});}exportasyncfunctionbug(){consts=`next`;if(!window[s]){for(window[s]=newDeferred();;)if(window.current)awaitwindow.current.promise;else{window.current=window[s];try{returnawaitwindow[s].promise// This line compressed to 'break'. I guess compressor intended jump to 23 line which is looks like same code.}finally{deletewindow.current// Above 'break' makes unintended delete}}}returnawaitwindow[s].promise}
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
Assume that the Deferred contained in window.current is resolved outside the script.
If normal, 'result' should appear when the logic below is executed.
However, minify with swc, the error below occurs.
This is because the logic in the try statement changes to 'break' and window.current is immediately deleted in finally.
The problem is reproduced even when only the
if_return
option of compressor is enabled.This problem does not occur with terser.
Input code
Config
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.3.99&code=H4sIAAAAAAAAA31SPU%2FDMBDd8yuOqamEUgnGiAGJhY2BDSHVTS6tm%2BQc%2BYO0qvLfOePEkAbwENn37r17fk7lqLBSETxhhVpjma7hkgAUioyFcizCA9iDNDkDUynrtGqlQYYIe3gJp7Sa9FKNRjUfeAsaj1jYIPuDP%2BLMH3f5Ne5pX7DfeHRY58mQJHjqlLYgzJkKiAN3bp9OQ4J7w%2BQt4clug7SsIL3pJZWqfzPvU69fldKQRmS80ncieb6OrZNQ6M4Kxy3EtxO9kBbm1SmjfMbGhlO7zEp%2BzansIfrJF71Wn39R8EujdZpmblghPtZmA6%2F8kNBIQk6p7Th7w%2B9rFax2GkW9yuAZ9o6rEeZsJFmkkvuOru188919kOgPsjiAF1Sq9rI1ghGt1y4xWzgcoJIkmuYv9yU2aPE6Cjb9uFP8q4wWoRU1GnAUbQXeclyyPIXv%2FzElwyeFShVWFwMAAA%3D%3D&config=H4sIAAAAAAAAA32VTY7bMAyF9zlF4HUXRQrMogformcQFItylFqiIVKZGIPcfei%2FTNpS3sX8%2BMzokaI%2FDsdjc6W2%2BXn8kJ%2FyMNhMkJ%2FPEqExsb1LpIE2WmpzGLj5ttErTcjbnmAOPRbSsM0d8Kyi0%2FfTaVU0PSLBplhjMaTgx9eaLcYhA9FLTKLyyhIhMf2tX1nGdw2cEXuwaQ8ZSyYkhg6yltZi39uBwNxshUdxLRCqRSZaGJwZMg56QnKBAyaJK9iBdaZFBxoLGVoON1CFUk%2BEieSQNezgXLpu7ve%2FHG62L5Y1Kdzn5shfVuAFA7HxRTVjgTUnFlpxOXiTgUueanIur%2BiKIdVkfwDEhd4SJRtVn%2BYML7NVh7vSkLzML48Kl2FXD5qgE2dNCF6zd7IHMge1ZAZXWpj8bXdwxQwKDgx4L0Oj4vfA7UUty%2BMA6DUijbbqMRZgqhdz5dP92MG%2F5KCsT9qaES1f6pTGeEb1Ym1y4Au6nQRpB2MdZ1kb96HOS3IgAwJOTSmkgunasmE0%2FbxD%2F58QuSjyTtP1eNbXxiATP3fyxxp7PFd2tKn7WgnL1j6sCU1EV2a4fg%2Bmxi9b%2FK35StoW9rNqE%2Bj3ppxu5%2BHxCZo7moVbBgAA
SWC Info output
Expected behavior
The logic inside the try statement remains.
Actual behavior
The logic inside the try statement is replaced with 'break'.
Version
1.3.99
Additional context
No response
The text was updated successfully, but these errors were encountered: