diff --git a/src/runtime/crt/common/crt_runtime_api.c b/src/runtime/crt/common/crt_runtime_api.c index 99b3201b95b0..57979b160ea7 100644 --- a/src/runtime/crt/common/crt_runtime_api.c +++ b/src/runtime/crt/common/crt_runtime_api.c @@ -349,9 +349,21 @@ int ModuleGetFunction(TVMValue* args, int* type_codes, int num_args, TVMValue* r ret_value[0].v_handle = NULL; ret_type_codes[0] = kTVMNullptr; - if (num_args != 3 || type_codes[0] != kTVMModuleHandle || type_codes[1] != kTVMStr || - type_codes[2] != kDLInt) { - return 0; + if (num_args != 3) { + TVMAPISetLastError("ModuleGetFunction expects exactly 3 arguments"); + return kTvmErrorFunctionCallNumArguments; + } + if (type_codes[0] != kTVMModuleHandle) { + TVMAPISetLastError("ModuleGetFunction expects first argument to be a Module"); + return kTvmErrorFunctionCallWrongArgType; + } + if (type_codes[1] != kTVMStr) { + TVMAPISetLastError("ModuleGetFunction expects second argument to be a string"); + return kTvmErrorFunctionCallWrongArgType; + } + if (type_codes[2] != kDLInt) { + TVMAPISetLastError("ModuleGetFunction expects third argument to be an integer"); + return kTvmErrorFunctionCallWrongArgType; } mod = (TVMModuleHandle)args[0].v_handle;