diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-09-07 20:21:15 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-09-07 20:21:15 -0700 |
commit | 08caf201b16922a6863009df91afdb92662da80e (patch) | |
tree | d9bdc83bdbe203fc9442aeed1f508d9c56e0dcc6 /eval.c | |
parent | febb7b777096ff9ea7106e1802ffabdd9449b727 (diff) | |
download | txr-08caf201b16922a6863009df91afdb92662da80e.tar.gz txr-08caf201b16922a6863009df91afdb92662da80e.tar.bz2 txr-08caf201b16922a6863009df91afdb92662da80e.zip |
Don't show whole function definition in args mismatch.
* eval.c (abbrev_ctx): New static function.
(bind_args): In too many/few args case, use abbrev_ctx to only
show function only when it is a lambda.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -441,6 +441,13 @@ static val env_vbind_special(val env, val sym, val obj, } } +static val abbrev_ctx(val ctx_form) +{ + if (car(ctx_form) == lambda_s) + return format(nil, lit(" for ~!~s"), ctx_form, nao); + return lit(""); +} + static val bind_args(val env, val params, struct args *args, val ctx_form) { val new_env = make_env(nil, nil, env); @@ -518,8 +525,8 @@ static val bind_args(val env, val params, struct args *args, val ctx_form) params = cdr(params); } if (!optargs) - eval_error(ctx_form, lit("~s: too few arguments for ~!~s\n"), - car(ctx_form), ctx_form, nao); + eval_error(ctx_form, lit("~s: too few arguments~!~a"), + car(ctx_form), abbrev_ctx(ctx_form), nao); while (consp(params)) { val param = car(params); if (param == colon_k) @@ -552,8 +559,8 @@ static val bind_args(val env, val params, struct args *args, val ctx_form) eval_error(ctx_form, lit("~s: ~s is not a bindable symbol"), car(ctx_form), params, nao); } else if (args_more(args, index)) { - eval_error(ctx_form, lit("~s: too many arguments for ~!~s"), - car(ctx_form), ctx_form, nao); + eval_error(ctx_form, lit("~s: too many arguments~!~a"), + car(ctx_form), abbrev_ctx(ctx_form), nao); } |