diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-06-17 22:14:48 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-06-17 22:14:48 -0700 |
commit | a3380a6ce354fc956635837d3fbca39b730d73aa (patch) | |
tree | 1f3d038022032f816f47d7a5278d2def3041ee16 /lib.c | |
parent | f15dcf205cb43804140db1f59314191e14d7ec65 (diff) | |
download | txr-a3380a6ce354fc956635837d3fbca39b730d73aa.tar.gz txr-a3380a6ce354fc956635837d3fbca39b730d73aa.tar.bz2 txr-a3380a6ce354fc956635837d3fbca39b730d73aa.zip |
* lib.c (generic_funcall): Bugfixes: support symbols.
Removed dubious statement which clamps nargs to the number
of fixed parameters, breaking variadic calls.
Test case: (mapcar 'list '(1 2)) -> ((1) (2))
Note: generic_funcall is only used when non-function objects
are used as functions; variadic funcalls were not broken.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -3456,6 +3456,17 @@ val generic_funcall(val fun, val arg[], int nargs) default: uw_throw(error_s, lit("call: too many arguments")); } + case SYM: + { + val binding = lookup_fun(nil, fun); + if (!binding) { + uw_throwf(error_s, lit("call: symbol ~s has no function binding"), + fun, nao); + abort(); + } + fun = cdr(binding); + } + break; case COBJ: if (fun->co.cls == hash_s) { switch (nargs) { @@ -3481,7 +3492,7 @@ val generic_funcall(val fun, val arg[], int nargs) if (!variadic) { if (nargs < reqargs) uw_throw(error_s, lit("call: missing required arguments")); - + if (nargs > fixparam) uw_throw(error_s, lit("call: too many arguments")); @@ -3521,9 +3532,6 @@ val generic_funcall(val fun, val arg[], int nargs) } else { val arglist = nil; - if (nargs > fixparam) - nargs = fixparam; - if (nargs < reqargs) uw_throw(error_s, lit("call: missing required arguments")); |