From 27a1694f51e78dc3350aa03b7eaba37277f57612 Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Wed, 4 Feb 2015 13:52:46 +0000 Subject: [PATCH 1/3] add test for #257 --- t/issue/257.scm | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 t/issue/257.scm diff --git a/t/issue/257.scm b/t/issue/257.scm new file mode 100644 index 00000000..8872be72 --- /dev/null +++ b/t/issue/257.scm @@ -0,0 +1,4 @@ +(import (scheme base) + (picrin test)) + +(map +) From 32831c11e0692e8744e768c6b022e4756d3dcab6 Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Wed, 4 Feb 2015 14:05:34 +0000 Subject: [PATCH 2/3] fix #257 --- extlib/benz/pair.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/extlib/benz/pair.c b/extlib/benz/pair.c index fc865921..1f1f3043 100644 --- a/extlib/benz/pair.c +++ b/extlib/benz/pair.c @@ -643,8 +643,12 @@ pic_pair_map(pic_state *pic) pic_value *args; pic_value arg, ret; + argc = 0; pic_get_args(pic, "l*", &proc, &argc, &args); + if (argc == 0) + pic_errorf(pic, "map: wrong number of arguments (1 for at least 2)"); + ret = pic_nil_value(); do { arg = pic_nil_value(); @@ -655,6 +659,7 @@ pic_pair_map(pic_state *pic) pic_push(pic, pic_car(pic, args[i]), arg); args[i] = pic_cdr(pic, args[i]); } + if (i != argc) { break; } From dfd6e453f3be031d2358945d94fdbb9d03f17ed7 Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Thu, 5 Feb 2015 05:51:39 +0000 Subject: [PATCH 3/3] remove unneeded argc initialization --- extlib/benz/pair.c | 1 - 1 file changed, 1 deletion(-) diff --git a/extlib/benz/pair.c b/extlib/benz/pair.c index 1f1f3043..36400af2 100644 --- a/extlib/benz/pair.c +++ b/extlib/benz/pair.c @@ -643,7 +643,6 @@ pic_pair_map(pic_state *pic) pic_value *args; pic_value arg, ret; - argc = 0; pic_get_args(pic, "l*", &proc, &argc, &args); if (argc == 0)