I've been working with google closure, trying to get a large body of JavaScript to compile cleanly for minimization using the Google compiler. I came across a problem though:
goog.provide('test');
goog.provide('test2');
/**
* @constructor
*/
test = function () {
this.x = 10;
this.y = 13;
};
(function () {
/**
* @constructor
*/
test2 = function () {
this.x = 10;
this.y = 13;
};
})();
The former is fine. The latter generates a constant-redefinition error:
JSC_CONSTANT_REASSIGNED_VALUE_ERROR. constant test2 assigned a value more than once at /home/hbrown/tmp/closure-test/foo.js line 16 : 10
BUILD FAILED: 1 error(s), 0 warning(s)
Is there some way to coerce plovr/closure compiler to allow this construct? I've looked around and found nothing.
Later: on a further point, why does closure/plovr consider test2 a constant? I suspect it has to do with plovr/closure's creation of a namespace for test2 when goog.provide is called. it would be nice to see the intermediate form that it is working with when it generates the error.