Google Closure calling undefined functions in advanced mode
Using Google Closure Compiler I have discovered that under certain
circumstances it will call an undefined local functions. The minimal
example that shows this that I have found is this:
var apa = {
/** @this {!Object} */
foo: function () { this.bar(id()); },
bar: function (x) { return [x]; }
};
apa.foo();
Which compiles to
(function(){this.a(id())})();
When compiling with closure --compilation_level ADVANCED_OPTIMIZATIONS.
The default compilation (without any options) compiles to this:
var
apa={foo:function(){this.bar(id())},bar:function(a){return[a]}};apa.foo();
In the minimal version this.a is undefined.
During my research I have not found any sign of any reason for this
behaviour and I'm honestly pretty confused about it. Is this a bug in
closure or me making some kind of faulty assumption?
(Any suggestion on how to fix this would be greatly appreciated since I'm
in great need of minimizing the js as much as humanly possible without
doing it by hand).
No comments:
Post a Comment