Open supersteves opened 8 years ago
Can you provide steps to repro from the command line? Some small input program and what compiler options you're using.
It'll be difficult, any ideas that might help me narrow it down?
Not sure, which is why I was hoping for a small repro :) The teammate who implemented this is on leave, so it'll take a bit of effort to dig into this and figure out what's going on.
I've already added an exception to our build, so there's no rush (speaking for myself). But I'll see if I can narrow it down.
I've narrowed it down somewhat. But can't find a testcase.
These 3 errors occur when I compile the largest monolithic part of our codebase. This includes a common script which registers a couple of old polyfills.
The same script is included by other builds which DON'T produce these warnings. So I have been unable to narrow it down in that way.
However I have whittled down the included common script to the bare minimum such that the 3 warnings still occur (when compiling the large monolithic code):
goog.provide("X");
(function (view) {
var objCtr = Object;
})(self);
My guess is some interplay between some other unknown part of my code and the above pattern is causing the issue. I can easily inspect in the Eclipse debugger when the warning is raised, if you can guide me to what you might need.
MapEntry is defined at https://github.com/google/closure-compiler/blob/f3aa05d1cba9da45467505183d1270ea90b1a67b/src/com/google/javascript/jscomp/js/es6/map.js#L75 and is not referenced in any other file. So I can't see why this would happen. If you're mixing the compiler's polyfills with polyfills from elsewhere that could cause some weirdness.
My Polyfill is a red herring; it's just the first provide, and I've commented out everything other than the 4 lines quoted above.
Somewhere in my ~5000 files is causing this. When the error is raised the NamedType ("MapEntry") arises from InstanceObjectType.properties, which contains just these entries:
{data_=Property { name: data_, type:Object<?,Array<MapEntry>>, inferred: false}, head_=Property { name: head_, type:MapEntry, inferred: false}, size=Property { name: size, type:number, inferred: false}}
These come from: https://github.com/google/closure-compiler/blob/f3aa05d1cba9da45467505183d1270ea90b1a67b/src/com/google/javascript/jscomp/js/es6/map.js#L109
The global scope's vars LinkedHashMap at the error raise has Map present (from externs?) but not MapEntry and not PolyfillMap.
I'm only checking types and have all optimisations disabled. But the same occurs with SIMPLE_OPTIMIZATIONS.
Any pointers to further debug?
I have the same problem, it is actually quite easy to reproduce. As the error itself suggests, you just need to use ES6 maps:
let x = new Map();
And then compile with: --warning_level VERBOSE --jscomp_warning=reportUnknownTypes
For others landing on this page,here is a workaround that shuts up the compiler for errors generated by its own polyfills:
--hide_warnings_for=synthetic
It's worth noting that reportUnknownTypes is not well-supported.
After compiling our very large codebase, we see these warnings:
We'll have to code in some exceptions, since we fail the build on warning. Presumably this is a bug, rather than something we're doing? Can't see how to put together a test case in the debugger here; this doesn't work.