mishoo/UglifyJS — Issue #256: problem in compressing label
Author: yyfrankyy
Created: 2011-11-23 07:14:07+00:00
State: open

I just found out that `uglifyjs` did not handle well when there were a variable and a label with the same name,

source:

function foo() {
console.log(bar.bar);
bar: {
console.log('h');
break bar
}
}
var bar = {bar: 1};
foo();

compress to:

function foo(){console.log(a.bar);a:{console.log("h");break a}}var bar={bar:1};foo();

beautify:

function foo() {
console.log(a.bar);
a : {
console.log("h");
break a;
}
}

var bar = {
bar: 1
};

foo();

so when I ran this compressed file, cause `a is not defined` error.

I do not meant to use label in my code, however, `closure compiler`(old version) use `function inlining`, which transformed inline function with recursion inside into label, so when I compressed the code which had been compressed once by `closure compiler`, this problem occurred.

btw, I found the same problem in latest version of `closure compiler`.