Opened 12 years ago

Closed 12 years ago

#3581 closed defect (duplicate)

Shrinksafe does not handle forward references to variable names correctly

Reported by: guest Owned by: James Burke
Priority: high Milestone:
Component: BuildTools Version: 0.9
Keywords: Cc:
Blocked By: Blocking:

Description

While shrinksafe works fine most of the time it has some problems with "forward references" to variable names. E.g.:

If you have code like this:

(function () {
    window.getSum = function() {
        return sum;
    }

    var sum = 13;
})();

shrinksafe "compresses" this to the following code:

(function(){
window.getSum=function(){
return sum;
};
var _1=13;
})();

As you can see the local variable sum is translated to _1, but the reference in the function is not changed.

Moving the var sum before the reference solves the issue:

(function () {
    var sum = 13;

    window.getSum = function() {
        return sum;
    }
})();

gets

(function(){
var _1=13;
window.getSum=function(){
return _1;
};
})();

(The CR #3241 seems to report this issue in a slightly different context)

Udo

Change History (1)

comment:1 Changed 12 years ago by James Burke

Resolution: duplicate
Status: newclosed

Closing as a duplicate of #3241, since it is the same issue. I'll reference this bug in the other bug though.

Note: See TracTickets for help on using tickets.