Skip to content

Commit

Permalink
[JSC] Improve TypeError message when WeakMap constructor takes an ite…
Browse files Browse the repository at this point in the history
…rable that yields invalid entry

https://bugs.webkit.org/show_bug.cgi?id=279015

Reviewed by Yusuke Suzuki.

This patch improves TypeError message when WeakMap constructor takes an iterable that yields invalid
entry.

* JSTests/stress/weak-map-constructor.js:
* Source/JavaScriptCore/runtime/WeakMapConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):

Canonical link: https://commits.webkit.org/283199@main
  • Loading branch information
sosukesuzuki committed Sep 5, 2024
1 parent 4df3b2c commit 060a2be
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion JSTests/stress/weak-map-constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ var notContainNextItem = [
];

for (var item of notContainNextItem) {
testTypeError(item);
testTypeError(item, "TypeError: WeakMap requires that an entry be an Object.");
testCallTypeError(item);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/runtime/WeakMapConstructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ JSC_DEFINE_HOST_FUNCTION(constructWeakMap, (JSGlobalObject* globalObject, CallFr
forEachInIterable(globalObject, iterable, [&](VM& vm, JSGlobalObject* globalObject, JSValue nextItem) {
auto scope = DECLARE_THROW_SCOPE(vm);
if (!nextItem.isObject()) {
throwTypeError(globalObject, scope);
throwTypeError(globalObject, scope, "WeakMap requires that an entry be an Object."_s);
return;
}

Expand Down

0 comments on commit 060a2be

Please sign in to comment.