]> git.kaiwu.me - quickjs.git/commitdiff
fix property ordering in the object returned by RegExp.prototype.exec()
authorFabrice Bellard <fabrice@bellard.org>
Tue, 22 Apr 2025 16:56:59 +0000 (18:56 +0200)
committerFabrice Bellard <fabrice@bellard.org>
Tue, 22 Apr 2025 16:56:59 +0000 (18:56 +0200)
quickjs.c

index e3e307426b4d4e2a43efc72a6ec98e1b2fe21d23..89e85010a5a246e1e742a13675d182589a688697 100644 (file)
--- a/quickjs.c
+++ b/quickjs.c
@@ -44108,12 +44108,6 @@ static JSValue js_regexp_exec(JSContext *ctx, JSValueConst this_val,
                 goto fail;
         }
 
-        t = groups, groups = JS_UNDEFINED;
-        if (JS_DefinePropertyValue(ctx, obj, JS_ATOM_groups,
-                                   t, prop_flags) < 0) {
-            goto fail;
-        }
-
         t = JS_NewInt32(ctx, (capture[0] - str_buf) >> shift);
         if (JS_DefinePropertyValue(ctx, obj, JS_ATOM_index, t, prop_flags) < 0)
             goto fail;
@@ -44122,6 +44116,12 @@ static JSValue js_regexp_exec(JSContext *ctx, JSValueConst this_val,
         if (JS_DefinePropertyValue(ctx, obj, JS_ATOM_input, t, prop_flags) < 0)
             goto fail;
 
+        t = groups, groups = JS_UNDEFINED;
+        if (JS_DefinePropertyValue(ctx, obj, JS_ATOM_groups,
+                                   t, prop_flags) < 0) {
+            goto fail;
+        }
+
         if (!JS_IsUndefined(indices)) {
             t = indices_groups, indices_groups = JS_UNDEFINED;
             if (JS_DefinePropertyValue(ctx, indices, JS_ATOM_groups,