Ticket #3581 (closed defect: duplicate)
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
Note: See
TracTickets for help on using
tickets.