From 1e958abcd83c4160d02b5a4d8fa2d451227a6771 Mon Sep 17 00:00:00 2001 From: Fabrice Bellard Date: Tue, 22 Apr 2025 18:59:21 +0200 Subject: [PATCH] fixed operation order in Object.prototype.propertyIsEnumerable() --- quickjs.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/quickjs.c b/quickjs.c index 89e8501..0268061 100644 --- a/quickjs.c +++ b/quickjs.c @@ -37312,6 +37312,7 @@ static __exception int JS_ObjectDefineProperties(JSContext *ctx, if (JS_IsException(props)) return -1; p = JS_VALUE_GET_OBJ(props); + /* XXX: not done in the same order as the spec */ if (JS_GetOwnPropertyNamesInternal(ctx, &atoms, &len, p, JS_GPN_ENUM_ONLY | JS_GPN_STRING_MASK | JS_GPN_SYMBOL_MASK) < 0) goto exception; for(i = 0; i < len; i++) { @@ -38268,17 +38269,17 @@ exception: static JSValue js_object_propertyIsEnumerable(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - JSValue obj, res = JS_EXCEPTION; - JSAtom prop = JS_ATOM_NULL; + JSValue obj = JS_UNDEFINED, res = JS_EXCEPTION; + JSAtom prop; JSPropertyDescriptor desc; int has_prop; - obj = JS_ToObject(ctx, this_val); - if (JS_IsException(obj)) - goto exception; prop = JS_ValueToAtom(ctx, argv[0]); if (unlikely(prop == JS_ATOM_NULL)) goto exception; + obj = JS_ToObject(ctx, this_val); + if (JS_IsException(obj)) + goto exception; has_prop = JS_GetOwnPropertyInternal(ctx, &desc, JS_VALUE_GET_OBJ(obj), prop); if (has_prop < 0)