diff --git a/src/vm/wren_primitive.c b/src/vm/wren_primitive.c index 17b045c1..3671e22f 100644 --- a/src/vm/wren_primitive.c +++ b/src/vm/wren_primitive.c @@ -23,9 +23,7 @@ static uint32_t validateIndexValue(WrenVM* vm, uint32_t count, double value, bool validateFn(WrenVM* vm, Value arg, const char* argName) { if (IS_CLOSURE(arg)) return true; - - vm->fiber->error = wrenStringFormat(vm, "$ must be a function.", argName); - return false; + RETURN_ERROR_FMT("$ must be a function.", argName); } bool validateNum(WrenVM* vm, Value arg, const char* argName) diff --git a/src/vm/wren_primitive.h b/src/vm/wren_primitive.h index 813300dc..d8cdbe98 100644 --- a/src/vm/wren_primitive.h +++ b/src/vm/wren_primitive.h @@ -43,17 +43,16 @@ return false; \ } while (false) -#define RETURN_ERROR_FMT(msg, arg) \ +#define RETURN_ERROR_FMT(...) \ do \ { \ - vm->fiber->error = wrenStringFormat(vm, msg, arg); \ + vm->fiber->error = wrenStringFormat(vm, __VA_ARGS__); \ return false; \ } while (false) // Validates that the given [arg] is a function. Returns true if it is. If not, // reports an error and returns false. bool validateFn(WrenVM* vm, Value arg, const char* argName); -bool validateFn(WrenVM* vm, Value arg, const char* argName); // Validates that the given [arg] is a Num. Returns true if it is. If not, // reports an error and returns false. diff --git a/src/vm/wren_vm.c b/src/vm/wren_vm.c index 194149c5..163b1ae7 100644 --- a/src/vm/wren_vm.c +++ b/src/vm/wren_vm.c @@ -1835,8 +1835,7 @@ void wrenGetVariable(WrenVM* vm, const char* module, const char* name, { ASSERT(module != NULL, "Module cannot be NULL."); ASSERT(name != NULL, "Variable name cannot be NULL."); - validateApiSlot(vm, slot); - + Value moduleName = wrenStringFormat(vm, "$", module); wrenPushRoot(vm, AS_OBJ(moduleName));