-
Notifications
You must be signed in to change notification settings - Fork 88
Description
Description:
When using NUglify to minify JavaScript code that contains a destructuring assignment with a spread operator, the resulting minified code is incorrect. Specifically, the variable names in the destructuring assignment are being incorrectly renamed, leading to potential runtime errors.
Steps to Reproduce:
- Use the following input code:
$m=(e,t,n,o,r,s)=>{const{uid:a=t,...i}=n;}
- Run the following C# code to minify the JavaScript:
var result = NUglify.Uglify.Js("$m=(e,t,n,o,r,s)=>{const{uid:a=t,...i}=n;}").Code; Console.WriteLine(result);
- Observe the output:
$m=(n,t,i)=>{const{uid:r=t,...i}=i}
Actual Behavior:
The minified code incorrectly renames variables in the destructuring assignment, leading to a broken structure:
$m=(n,t,i)=>{const{uid:r=t,...i}=i}Here, the variable i is reused both as the object being destructured and as the rest parameter, which is invalid and will cause runtime errors.
Environment:
- NUglify Version: 1.21.13
Additional Notes:
This issue seems to occur specifically when destructuring assignments involve a default value (uid:a=t) and a spread operator (...i). It appears that the variable renaming logic in NUglify is not handling these cases correctly.