Open
Description
See this example in which we define a @record
type inside an IIFE that should shadow an extern type Foo
:
Externs:
/** @record */ var Foo = function() {};
/** @type {number} */ Foo.prototype.foo;
function sink(arg) {}
Main:
sink(function() {
/** @record */ var Foo = function() {};
/** @type {string} */ Foo.prototype.bar;
/** @return {!Foo} */
var handle = function() { return /** @type {!Foo} */ ({}); };
sink(handle().bar);
});
Per #1729, the compiler can't handle shadowing the extern, and if the main code defined a @constructor
instead of a @record
, we would get an explicit error message saying so. But for @record
s, we instead get a very cryptic message:
input0:8: WARNING - Property bar never defined on Foo
sink(handle().bar);
^
which is complete nonsense because as you can clearly see, I did define bar
. Hopefully fixing #1729 will take care of this, but there's also another bug somewhere where we're not reporting that a @record
declaration didn't actually stick.