summaryrefslogtreecommitdiff
path: root/enumerator.c
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-14 07:42:43 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-14 07:42:43 +0000
commit8ca504214d8a20bdda05b65016812fa7234faad4 (patch)
tree5c23c1b9ca2f01c8c01d7b21d0b7c54fd87debdf /enumerator.c
parenta4665e30f72bc42a9b12b8751ce73ad282ccc5f6 (diff)
* enumerator.c: Require block for Lazy#{take|drop}_while [Bug #7692]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enumerator.c')
-rw-r--r--enumerator.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/enumerator.c b/enumerator.c
index d488093ce8..7a7cc1de83 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -1678,6 +1678,9 @@ lazy_take_while_func(VALUE val, VALUE args, int argc, VALUE *argv)
static VALUE
lazy_take_while(VALUE obj)
{
+ if (!rb_block_given_p()) {
+ rb_raise(rb_eArgError, "tried to call lazy take_while without a block");
+ }
return lazy_set_method(rb_block_call(rb_cLazy, id_new, 1, &obj,
lazy_take_while_func, 0),
Qnil, 0);
@@ -1745,6 +1748,9 @@ lazy_drop_while(VALUE obj)
{
NODE *memo;
+ if (!rb_block_given_p()) {
+ rb_raise(rb_eArgError, "tried to call lazy drop_while without a block");
+ }
memo = NEW_MEMO(0, 0, FALSE);
return lazy_set_method(rb_block_call(rb_cLazy, id_new, 1, &obj,
lazy_drop_while_func, (VALUE) memo),