commit 8beb03f703a121fde00cfcb284f43fa9de5c4390
parent 50d3ecf044efdcf8830af3f4487b81da741bd055
Author: Ed van Bruggen <edvb@uw.edu>
Date: Fri, 30 Mar 2018 21:47:50 -0700
cxr: Evalulate arguments before checking type
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tisp.c b/tisp.c
@@ -424,10 +424,10 @@ static Val
prim_car(Hash env, Val args)
{
Val v;
- if (car(args)->t != PAIR)
- warnf("car: expected list, recieved type [%d]", car(args)->t);
if (!(v = eval_list(env, args)))
return NULL;
+ if (v->t != PAIR)
+ warnf("car: expected list, recieved type [%d]", car(args)->t);
return car(car(v));
}
@@ -435,10 +435,10 @@ static Val
prim_cdr(Hash env, Val args)
{
Val v;
- if (car(args)->t != PAIR)
- warnf("cdr: expected list, recieved type [%d]", car(args)->t);
if (!(v = eval_list(env, args)))
return NULL;
+ if (v->t != PAIR)
+ warnf("cdr: expected list, recieved type [%d]", car(args)->t);
return cdr(car(v));
}