1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 14:00:21 +02:00

bind-rest works in the optional-and-rest-arg case.

* libguile/vm-engine.c (bind-rest): If the sp is below the dst reg,
  alloc the frame to ensure there is enough space, and to fill in
  intermediate values with SCM_UNDEFINED.
This commit is contained in:
Andy Wingo 2013-10-14 21:45:48 +02:00
parent 99511cd0ab
commit 234155e336

View file

@ -1586,16 +1586,25 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t nargs_)
SCM_UNPACK_RTL_24 (op, dst);
nargs = FRAME_LOCALS_COUNT ();
while (nargs-- > dst)
if (nargs <= dst)
{
rest = scm_cons (LOCAL_REF (nargs), rest);
LOCAL_SET (nargs, SCM_UNDEFINED);
ALLOC_FRAME (dst + 1);
while (nargs < dst)
LOCAL_SET (nargs++, SCM_UNDEFINED);
}
else
{
while (nargs-- > dst)
{
rest = scm_cons (LOCAL_REF (nargs), rest);
LOCAL_SET (nargs, SCM_UNDEFINED);
}
RESET_FRAME (dst + 1);
}
LOCAL_SET (dst, rest);
RESET_FRAME (dst + 1);
NEXT (1);
}