Open loilo opened 7 years ago
If the second variable has no value attached, the variable name itself will be appended to the first variable's value.
Input:
for ( let counter_var = 1, another_var; any_evaluation(); counter_var++ ) {}
Output Butternut: (different variable names than in the issue description due to new char frequency dependant naming in 0.4.6)
for(let f=1r;any_evaluation();f++);
Output UglifyJS:
for(let f=1;any_evaluation();f++);
From squashing minified ajv.
When Butternut encounters a secondary variable initialization in the first part of a
for
loop head, and that secondary variable is no further used, the variable will be removed while the value will be kept in place. This leads to syntax errors or even non-errors with semantically wrong code.Example 1: Syntax error
Input:
Output Butternut:
Output UglifyJS:
Example 2: Modified semantics
Input: Just use a number as the value instead of the empty array.
Output Butternut:
Output UglifyJS:
Side note: Both examples are also working with
var
instead oflet
, but only inside an IIFE.