You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[JSC] Improve error message for calling constructor without new
https://bugs.webkit.org/show_bug.cgi?id=298927
Reviewed by Yusuke Suzuki.
Calling constructors without `new` is invalid:
class Foo {}
Foo();
Current JSC throws a TypeError with the message "Cannot call a class
constructor without |new|" for such code.
This patch changes this error message to include the constructor name
for debugging experience.
Test: JSTests/stress/constructor-call-without-new.js
Test: JSTests/stress/constructor-call-without-new.js
* JSTests/stress/calling-non-callable-constructors.js:
(shouldThrow):
* JSTests/stress/constructor-call-without-new.js: Added.
(shouldThrow):
(throw.new.Error):
* JSTests/stress/constructor-kind-naked-should-not-be-applied-to-inner-functions.js:
(shouldThrow.Promise):
* JSTests/stress/promise-cannot-be-called.js:
(shouldThrow):
* LayoutTests/js/Promise-types-expected.txt:
* LayoutTests/js/class-syntax-call-expected.txt:
* LayoutTests/js/class-syntax-default-constructor-expected.txt:
* LayoutTests/js/script-tests/Promise-types.js:
* LayoutTests/js/script-tests/class-syntax-call.js:
* LayoutTests/js/script-tests/class-syntax-default-constructor.js:
* LayoutTests/performance-api/performance-observer-exception-expected.txt:
* Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::BytecodeGenerator):
Canonical link: https://commits.webkit.org/301023@main
0 commit comments