diff --git a/femtolisp/flisp.c b/femtolisp/flisp.c index 802597b..8150d6d 100644 --- a/femtolisp/flisp.c +++ b/femtolisp/flisp.c @@ -1163,7 +1163,8 @@ static value_t eval_sexpr(value_t e, uint32_t penv, int tail) f = Stack[SP-5]; Stack[SP-3] = car_(f); // lambda list Stack[SP-2] = fixnum(s); // argument value - v = eval_sexpr(car_(cdr_(f)), SP-3, 0); + v = car_(cdr_(f)); + if (!selfevaluating(v)) v = eval_sexpr(v, SP-3, 0); } break; case F_SPECIAL_APPLY: diff --git a/femtolisp/unittest.lsp b/femtolisp/unittest.lsp index 606993c..4671e07 100644 --- a/femtolisp/unittest.lsp +++ b/femtolisp/unittest.lsp @@ -66,6 +66,8 @@ (assert (equal (string 'sym #char(65) #wchar(945) "blah") "symA\u03B1blah")) +; this crashed once +(for 1 10 (lambda (i) 0)) ; ok, a couple end-to-end tests as well (define (fib n) (if (< n 2) n (+ (fib (- n 1)) (fib (- n 2)))))