]> git.kaiwu.me - quickjs.git/commitdiff
setters cannot have rest arguments
authorFabrice Bellard <fabrice@bellard.org>
Tue, 22 Apr 2025 16:53:48 +0000 (18:53 +0200)
committerFabrice Bellard <fabrice@bellard.org>
Tue, 22 Apr 2025 16:53:48 +0000 (18:53 +0200)
quickjs.c

index ba021b769b67bde2e792d3d54cf6e9faadf09d52..e3e307426b4d4e2a43efc72a6ec98e1b2fe21d23 100644 (file)
--- a/quickjs.c
+++ b/quickjs.c
@@ -34126,6 +34126,8 @@ static __exception int js_parse_function_decl2(JSParseState *s,
             int idx, has_initializer;
 
             if (s->token.val == TOK_ELLIPSIS) {
+                if (func_type == JS_PARSE_FUNC_SETTER)
+                    goto fail_accessor;
                 fd->has_simple_parameter_list = FALSE;
                 rest = TRUE;
                 if (next_token(s))
@@ -34239,6 +34241,7 @@ static __exception int js_parse_function_decl2(JSParseState *s,
         }
         if ((func_type == JS_PARSE_FUNC_GETTER && fd->arg_count != 0) ||
             (func_type == JS_PARSE_FUNC_SETTER && fd->arg_count != 1)) {
+        fail_accessor:
             js_parse_error(s, "invalid number of arguments for getter or setter");
             goto fail;
         }