Skip to content

JS variable renaming breaks scripts #326

@simonmicro

Description

@simonmicro

minify triggers an Unexpected identifier syntax error with the code below...

var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
var something = 42;
something++;
for (let i = 0; i < 10; i++) {
    let badboy = 10;
    badboy++;
}

It results in...

var something=42,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a;something++;for(let a=0;a<10;a++)let b=10,b++

Note that the variable a is both used in the var AND let scope and causes an syntax error (test it here)!

Or to put it into the tools own words:

ERROR: cannot minify /app/src/examplenew.js: unexpected b in expression on line 1 and column 107
    1: ...omething++;for(let a=0;a<10;a++)let b=10,b++

When I don't mix var and let it works fine...

I must admit that we use this wonderful tool also at work and yeah... It broke our release version for about 10 minutes - very not good...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions