Ticket #3581 (closed defect: duplicate)

Opened 19 months ago

Last modified 19 months ago

Shrinksafe does not handle forward references to variable names correctly

Reported by: guest Owned by: jburke
Priority: normal Milestone:
Component: BuildTools Version: 0.9
Severity: normal Keywords:
Cc:

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

Changed 19 months ago by jburke

  • status changed from new to closed
  • resolution set to duplicate

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.