diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2025-04-15 11:26:53 +0200 |
---|---|---|
committer | Fabrice Bellard <fabrice@bellard.org> | 2025-04-15 11:26:53 +0200 |
commit | 5449fd42d62e5f3fda38736475f7c65c133b5cd2 (patch) | |
tree | 7a878f44daf74f2a7c34c4819fbbbc0755416537 /quickjs.c | |
parent | 8f99de5b7faa82d07e0ebd5489f6e99a8554d77c (diff) | |
download | quickjs-5449fd42d62e5f3fda38736475f7c65c133b5cd2.tar.gz quickjs-5449fd42d62e5f3fda38736475f7c65c133b5cd2.zip |
more ToPropertyKey ordering changes
Diffstat (limited to 'quickjs.c')
-rw-r--r-- | quickjs.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -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)) |