more ToPropertyKey ordering changes

This commit is contained in:
Fabrice Bellard
2025-04-15 11:26:53 +02:00
parent 8f99de5b7f
commit 5449fd42d6
3 changed files with 10 additions and 5 deletions

View File

@@ -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))