fixed a compiler bug that didn't check the number of arguments to a primitive function properly when no parameter was given

This commit is contained in:
hyung-hwan 2018-02-24 01:28:58 +00:00
parent a4be9907b7
commit a5fe90597c

View File

@ -1365,6 +1365,7 @@ static int compile_cons_xlist_expression (hcl_t* hcl, hcl_oop_t obj)
hcl_ooi_t oldtop;
hcl_cframe_t* cf;
hcl_oop_t cdr;
hcl_oop_cons_t sdc;
/* NOTE: cframe management functions don't use the object memory.
* many operations can be performed without taking GC into account */
@ -1382,15 +1383,14 @@ static int compile_cons_xlist_expression (hcl_t* hcl, hcl_oop_t obj)
/* compile <operand1> ... etc */
cdr = HCL_CONS_CDR(obj);
if (HCL_IS_NIL(hcl, cdr))
{
nargs = 0;
}
else
{
hcl_oop_cons_t sdc;
if (!HCL_IS_CONS(hcl, cdr))
if (!HCL_IS_NIL(hcl, cdr) && !HCL_IS_CONS(hcl, cdr))
{
/* (funname . 10) */
hcl_setsynerrbfmt (hcl, HCL_SYNERR_DOTBANNED, HCL_NULL, HCL_NULL, "redundant cdr in function call - %O", obj); /* TODO: error location */
@ -1403,6 +1403,7 @@ static int compile_cons_xlist_expression (hcl_t* hcl, hcl_oop_t obj)
hcl_setsynerrbfmt (hcl, HCL_SYNERR_ARGFLOOD, HCL_NULL, HCL_NULL, "too many(%zd) parameters in function call - %O", nargs, obj);
return -1;
}
}
sdc = hcl_getatsysdic(hcl, car);
if (sdc)
@ -1419,7 +1420,7 @@ static int compile_cons_xlist_expression (hcl_t* hcl, hcl_oop_t obj)
}
}
};
}
/* redundant cdr check is performed inside compile_object_list() */
PUSH_SUBCFRAME (hcl, COP_COMPILE_ARGUMENT_LIST, cdr);