diff options
author | Andy Wingo <wingo@pobox.com> | 2013-10-17 23:19:57 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2013-10-17 23:20:32 +0200 |
commit | e93c0430faf34cc881d4d87750bd2cdad2dd9813 (patch) | |
tree | c071f3bd4be0edf3d195f7a99e0c5e4955f70b78 /libguile/vm-engine.c | |
parent | 73c3db666926aa4a0307ea0ed4b38608a31ecd82 (diff) | |
download | guile-e93c0430faf34cc881d4d87750bd2cdad2dd9813.tar.gz |
Fix tail-apply bugs
* libguile/vm-engine.c (tail-apply): Fix for old change that made
the procedure indexed 0 instead of -1.
Diffstat (limited to 'libguile/vm-engine.c')
-rw-r--r-- | libguile/vm-engine.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c index 76c00d772..076134419 100644 --- a/libguile/vm-engine.c +++ b/libguile/vm-engine.c @@ -1292,24 +1292,25 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t nargs_) */ VM_DEFINE_OP (11, tail_apply, "tail-apply", OP1 (U8_X24)) { - int i, list_idx, list_len, nargs; + int i, list_idx, list_len, nlocals; SCM list; VM_HANDLE_INTERRUPTS; - VM_ASSERT (FRAME_LOCALS_COUNT () >= 2, abort ()); - nargs = FRAME_LOCALS_COUNT (); - list_idx = nargs - 1; + nlocals = FRAME_LOCALS_COUNT (); + // At a minimum, there should be apply, f, and the list. + VM_ASSERT (nlocals >= 3, abort ()); + list_idx = nlocals - 1; list = LOCAL_REF (list_idx); list_len = scm_ilength (list); VM_ASSERT (list_len >= 0, vm_error_apply_to_non_list (list)); - nargs = nargs - 2 + list_len; - ALLOC_FRAME (nargs); + nlocals = nlocals - 2 + list_len; + ALLOC_FRAME (nlocals); - for (i = 0; i < list_idx; i++) - LOCAL_SET(i - 1, LOCAL_REF (i)); + for (i = 1; i < list_idx; i++) + LOCAL_SET (i - 1, LOCAL_REF (i)); /* Null out these slots, just in case there are less than 2 elements in the list. */ |