diff options
-rw-r--r-- | eval.c | 7 | ||||
-rw-r--r-- | tests/012/lambda.tl | 14 |
2 files changed, 17 insertions, 4 deletions
@@ -973,11 +973,10 @@ static val bind_args(val env, val params, struct args *args, val ctx) val present = nil; if (arg == colon_k) { - if (initform) { + if (initform) initval = eval(initform, new_env, ctx); - new_env = lex_or_dyn_bind_seq(&dyn_env_made, new_env, - param, initval); - } + new_env = lex_or_dyn_bind_seq(&dyn_env_made, new_env, + param, initval); } else { lex_or_dyn_bind(&dyn_env_made, new_env, param, arg); present = t; diff --git a/tests/012/lambda.tl b/tests/012/lambda.tl index 5267e4ef..65a3738c 100644 --- a/tests/012/lambda.tl +++ b/tests/012/lambda.tl @@ -87,6 +87,20 @@ [(lambda (x y : (a 3) (b 4)) (list x y a b)) . vl] (a b c d) [(lambda (x y : (a 3) (b 4)) (list x y a b)) 1 . vl] :error) +(mtest + [(lambda (x : y) (list x y)) 1 :] (1 nil) + [(lambda (x : y z) (list x y z)) 1 :] (1 nil nil) + [(lambda (x : y z) (list x y z)) 1 2 :] (1 2 nil) + [(lambda (x : y z) (list x y z)) 1 nil :] (1 nil nil) + [(lambda (x : y z) (list x y z)) 1 nil nil] (1 nil nil)) + +(mtest + [(lambda (x : (y nil)) (list x y)) 1 :] (1 nil) + [(lambda (x : (y nil) (z)) (list x y z)) 1 :] (1 nil nil) + [(lambda (x : (y nil) (z)) (list x y z)) 1 2 :] (1 2 nil) + [(lambda (x : (y nil) (z)) (list x y z)) 1 nil :] (1 nil nil) + [(lambda (x : (y nil) (z)) (list x y z)) 1 nil nil] (1 nil nil)) + (defvarl vc '(: : : :)) (mtest |