From c3e1226e96fafd2450ec7bc47900de1d5fdaf3db Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Sun, 20 Nov 2022 09:20:14 +0900 Subject: [PATCH] Just extract the argument outside of matchType --- src/parseargs.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/parseargs.c b/src/parseargs.c index a5bbf81..38e9f8b 100644 --- a/src/parseargs.c +++ b/src/parseargs.c @@ -9,8 +9,7 @@ * module is not loaded, but may still need to be referenced as a potential * type in a function like @c print ). */ -static int matchType(const char * _method_name, va_list * args, KrkValue arg) { - KrkClass * type = va_arg(*args, KrkClass*); +static int matchType(const char * _method_name, KrkClass * type, KrkValue arg) { if (arg != KWARGS_VAL(0) && !krk_isInstanceOf(arg, type)) { krk_runtimeError(vm.exceptions->typeError, "%s() expects %s, not '%T'", _method_name, type ? type->name->chars : "unknown type", arg); @@ -155,7 +154,8 @@ int krk_parseVArgs( case 'O': { if (fmt[1] == '!') { fmt++; - if (!matchType(_method_name, &args, arg)) goto _error; + KrkClass * type = va_arg(args, KrkClass*); + if (!matchType(_method_name, type, arg)) goto _error; } KrkObj ** out = va_arg(args, KrkObj**); if (arg != KWARGS_VAL(0)) { @@ -183,7 +183,8 @@ int krk_parseVArgs( case 'V': { if (fmt[1] == '!') { fmt++; - if (!matchType(_method_name, &args, arg)) goto _error; + KrkClass * type = va_arg(args, KrkClass*); + if (!matchType(_method_name, type, arg)) goto _error; } KrkValue * out = va_arg(args, KrkValue*); if (arg != KWARGS_VAL(0)) {