-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'catch' is not supported as a method name in object literals #2640
Comments
This looks correct to me. There is nothing to tell the compiler that |
I see what you mean. I must have oversimplified the actual case and removed too much. The actual code also exports MyPromise into the global scope. Still simplified it looks like that: (function () {
'use strict';
function MyPromise(resolver) {
}
MyPromise.prototype = {
constructor: MyPromise,
then: function() {},
catch(onRejection) {
return this.then(null, onRejection);
}
};
let local;
try {
local = Function('return this')();
} catch (e) {
throw new Error('polyfill failed because global object is unavailable in this environment');
}
local.Promise = MyPromise;
let p = new Promise();
console.log(`typeof promise.catch = ${typeof p['catch']}`);
}()); The actual (non simplified) file where the issue occurs is attached as well. |
That's still not enough for advanced mode. |
In certain cases Google Closure Compiler incorrectly removes the method called
catch
from object literals.Example (sample.js):
Executing an unprocessed file yields:
Executing a compiled file yields an incorrect result:
The issue appears with the last released version of the compiler:
The code sample above is reduced from es6-promise polyfill which is used among others in the WebComponents polyfill.
The text was updated successfully, but these errors were encountered: