summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-08-05 07:14:47 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-08-05 07:14:47 -0700
commit0fe8e3d8a566dbd82dede5c392224d23245fb0f8 (patch)
tree2ca8258ae3d3312e736c7dbf5a0214b5335416c5 /lib.c
parent1b8382aaa0f95f95c7bc85d69c70129aacbc2fa6 (diff)
downloadtxr-0fe8e3d8a566dbd82dede5c392224d23245fb0f8.tar.gz
txr-0fe8e3d8a566dbd82dede5c392224d23245fb0f8.tar.bz2
txr-0fe8e3d8a566dbd82dede5c392224d23245fb0f8.zip
Better diagnostic in funcall family of functions.
* lib.c (wrongargs): New static function. (funcall, funcall2, funcall2, funcall3, funcall4): Use wrongargs.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib.c b/lib.c
index e954d932..65394f76 100644
--- a/lib.c
+++ b/lib.c
@@ -4411,6 +4411,15 @@ val generic_funcall(val fun, val arg[], int nargs)
internal_error("corrupt function type field");
}
+static noreturn void wrongargs(val fun)
+{
+ uses_or2;
+ prinl(last_form_evaled, nil);
+ uw_throwf(error_s, lit("~s: wrong number of arguments"),
+ or2(func_get_name(fun, nil), fun), nao);
+ abort();
+}
+
val funcall(val fun)
{
if (type(fun) != FUN || fun->f.optargs) {
@@ -4439,7 +4448,7 @@ val funcall(val fun)
break;
}
}
- uw_throw(error_s, lit("call: wrong number of arguments"));
+ wrongargs(fun);
}
val funcall1(val fun, val arg)
@@ -4475,7 +4484,7 @@ val funcall1(val fun, val arg)
break;
}
}
- uw_throw(error_s, lit("call: wrong number of arguments"));
+ wrongargs(fun);
}
val funcall2(val fun, val arg1, val arg2)
@@ -4517,7 +4526,7 @@ val funcall2(val fun, val arg1, val arg2)
break;
}
}
- uw_throw(error_s, lit("call: wrong number of arguments"));
+ wrongargs(fun);
}
val funcall3(val fun, val arg1, val arg2, val arg3)
@@ -4564,7 +4573,7 @@ val funcall3(val fun, val arg1, val arg2, val arg3)
break;
}
}
- uw_throw(error_s, lit("call: wrong number of arguments"));
+ wrongargs(fun);
}
val funcall4(val fun, val arg1, val arg2, val arg3, val arg4)
@@ -4616,7 +4625,7 @@ val funcall4(val fun, val arg1, val arg2, val arg3, val arg4)
break;
}
}
- uw_throw(error_s, lit("call: wrong number of arguments"));
+ wrongargs(fun);
}
val reduce_left(val fun, val list, val init, val key)