Commit 5f852e4a authored by Chris Müller's avatar Chris Müller
Browse files

No segfault when a missing argument appear in if statement

parent f120cf03
......@@ -707,14 +707,45 @@ org_cherry_transform_define(struct org_cherry_value* value)
}
static struct org_cherry_value*
org_cherry_transform_if(struct org_cherry_value* value)
{
struct org_cherry_value* pred = org_cherry_false;
struct org_cherry_value* tru = org_cherry_false;
struct org_cherry_value* fal = org_cherry_false;
// check predicate
if(IS_NULL(TAIL(value)))
pred = TAIL(value) = org_cherry_list_cons(pred, org_cherry_emptylist);
else
pred = TAIL(value);
// check true case
if(IS_NULL(TAIL(pred)))
tru = TAIL(pred) = org_cherry_list_cons(tru, org_cherry_emptylist);
else
tru = TAIL(pred);
// check false case
if(IS_NULL(TAIL(tru)))
fal = TAIL(tru) = org_cherry_list_cons(fal, org_cherry_emptylist);
else
fal = TAIL(tru);
return value;
}
static struct org_cherry_value*
org_cherry_transform(struct org_cherry_value* value)
{
if(IS_TRY(value))
return org_cherry_transform_try(TAIL(value));
else if(IS_DEFINE(value)) {
else if(IS_DEFINE(value))
return org_cherry_transform_define(TAIL(value));
} else
else if(IS_IF(value))
return org_cherry_transform_if(value);
else
return value;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment