Skip to content

Failed @record declarations aren't reported correctly #1730

Open
@shicks

Description

@shicks

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 @records, 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions