summaryrefslogtreecommitdiff
path: root/quickjs.c
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2025-04-15 11:26:53 +0200
committerFabrice Bellard <fabrice@bellard.org>2025-04-15 11:26:53 +0200
commit5449fd42d62e5f3fda38736475f7c65c133b5cd2 (patch)
tree7a878f44daf74f2a7c34c4819fbbbc0755416537 /quickjs.c
parent8f99de5b7faa82d07e0ebd5489f6e99a8554d77c (diff)
downloadquickjs-5449fd42d62e5f3fda38736475f7c65c133b5cd2.tar.gz
quickjs-5449fd42d62e5f3fda38736475f7c65c133b5cd2.zip
more ToPropertyKey ordering changes
Diffstat (limited to 'quickjs.c')
-rw-r--r--quickjs.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/quickjs.c b/quickjs.c
index 31375c5..4187cab 100644
--- a/quickjs.c
+++ b/quickjs.c
@@ -8355,6 +8355,11 @@ static JSValue JS_GetPropertyValue(JSContext *ctx, JSValueConst this_obj,
}
} else {
slow_path:
+ /* ToObject() must be done before ToPropertyKey() */
+ if (JS_IsNull(this_obj) || JS_IsUndefined(this_obj)) {
+ JS_FreeValue(ctx, prop);
+ return JS_ThrowTypeError(ctx, "cannot read property of %s", JS_IsNull(this_obj) ? "null" : "undefined");
+ }
atom = JS_ValueToAtom(ctx, prop);
JS_FreeValue(ctx, prop);
if (unlikely(atom == JS_ATOM_NULL))
@@ -22789,6 +22794,10 @@ static __exception int js_parse_object_literal(JSParseState *s)
}
emit_u8(s, op_flags | OP_DEFINE_METHOD_ENUMERABLE);
} else {
+ if (name == JS_ATOM_NULL) {
+ /* must be done before evaluating expr */
+ emit_op(s, OP_to_propkey);
+ }
if (js_parse_expect(s, ':'))
goto fail;
if (js_parse_assign_expr(s))