Skip to content
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

Constructors of ES classes require new but the runtime doesn't check it #2919

Open
teppeis opened this issue May 11, 2018 · 0 comments
Open

Comments

@teppeis
Copy link
Contributor

teppeis commented May 11, 2018

In ES2015+, calling constructors of classes and builtin classes (Map, Set, WeakMap and WeakSet) without new throws TypeError.

Map(); // throws `TypeError`

https://www.ecma-international.org/ecma-262/6.0/#sec-map-iterable

In Closure Compiler ADVANCED mode, JSC_CONSTRUCTOR_NOT_CALLABLE warning is correctly thrown in compile time.
But in SIMPLE or WHITESPACE_ONLY mode, no warnings are detected in compile time and the runtime doesn't throw any errors.

Should the polyfill runtime of Closure Compiler for the constructors throw runtime error for SIMPLE and WHITESPACE_ONLY mode?

I will send a PR if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant