Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -10556,9 +10556,15 @@ static int JS_SetPropertyInternal2(JSContext *ctx, JSValueConst obj, JSAtom prop

switch(JS_VALUE_GET_TAG(this_obj)) {
case JS_TAG_NULL:
if (JS_IsObject(obj)) {
goto primitive_receiver;
}
JS_ThrowTypeErrorAtom(ctx, "cannot set property '%s' of null", prop);
goto fail;
case JS_TAG_UNDEFINED:
if (JS_IsObject(obj)) {
goto primitive_receiver;
}
JS_ThrowTypeErrorAtom(ctx, "cannot set property '%s' of undefined", prop);
goto fail;
case JS_TAG_OBJECT:
Expand All @@ -10570,6 +10576,8 @@ static int JS_SetPropertyInternal2(JSContext *ctx, JSValueConst obj, JSAtom prop
default:
if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT)
obj = JS_GetPrototypePrimitive(ctx, obj);

primitive_receiver:
p = NULL;
p1 = JS_VALUE_GET_OBJ(obj);
goto prototype_lookup;
Expand Down
5 changes: 5 additions & 0 deletions tests/bug1730.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { assert } from "./assert.js";

assert(Reflect.set({ set x(v) {} }, "x", 1, null), true);
assert(Reflect.set({}, "x", 1, undefined), false);
assert(Reflect.set({}, "x", 1, null), false);
Loading