Skip to content

Commit

Permalink
Add Symbol key support to WeakMap
Browse files Browse the repository at this point in the history
  • Loading branch information
saghul committed Nov 13, 2023
1 parent 7926755 commit 109e541
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -43650,8 +43650,14 @@ static JSValue js_map_set(JSContext *ctx, JSValueConst this_val,
if (!s)
return JS_EXCEPTION;
key = map_normalize_key(ctx, argv[0]);
if (s->is_weak && !JS_IsObject(key))
return JS_ThrowTypeErrorNotAnObject(ctx);
if (s->is_weak) {
if (magic & MAGIC_SET) {
if (!JS_IsObject(key))
return JS_ThrowTypeErrorNotAnObject(ctx);
} else if (!JS_IsObject(key) && !JS_IsSymbol(key)) {
return JS_ThrowTypeError(ctx, "key must be Objecty or Symbol");
}
}
if (magic & MAGIC_SET)
value = JS_UNDEFINED;
else
Expand Down

0 comments on commit 109e541

Please sign in to comment.