summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-12-12 06:29:11 +0900
committerKoichi Sasada <ko1@atdot.net>2020-12-12 06:29:11 +0900
commit124321e0c7ab8dac1ffce78c653cc677f878d5b0 (patch)
tree53be2cc7989b0392b57ca78afb03b9c4fc9b2b0d /proc.c
parentd741c77b5fd976300815c1ea987e76e92b71122f (diff)
downloadruby-124321e0c7ab8dac1ffce78c653cc677f878d5b0.tar.gz
fix lambda's warning and tests
There are warning condition bugs and test bugs. b53ccb9c69abd24e3bdad66cbe4c7e7480eaef16
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/proc.c b/proc.c
index 7e1985ceb1..749b6a8134 100644
--- a/proc.c
+++ b/proc.c
@@ -847,16 +847,8 @@ rb_block_lambda(void)
return proc_new(rb_cProc, TRUE, FALSE);
}
-/*
- * call-seq:
- * lambda { |...| block } -> a_proc
- *
- * Equivalent to Proc.new, except the resulting Proc objects check the
- * number of parameters passed when called.
- */
-
-static VALUE
-f_lambda(VALUE _)
+static void
+f_lambda_warn(void)
{
rb_control_frame_t *cfp = GET_EC()->cfp;
VALUE block_handler = rb_vm_frame_block_handler(cfp);
@@ -865,20 +857,36 @@ f_lambda(VALUE _)
switch (vm_block_handler_type(block_handler)) {
case block_handler_type_iseq:
if (RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)->ep == VM_BH_TO_ISEQ_BLOCK(block_handler)->ep) {
- break;
+ return;
}
- case block_handler_type_symbol:
break;
+ case block_handler_type_symbol:
+ return;
case block_handler_type_proc:
if (rb_proc_lambda_p(VM_BH_TO_PROC(block_handler))) {
- break;
+ return;
}
+ break;
case block_handler_type_ifunc:
- rb_warn_deprecated("lambda without a literal block", "the proc without lambda");
break;
}
}
+ rb_warn_deprecated("lambda without a literal block", "the proc without lambda");
+}
+
+/*
+ * call-seq:
+ * lambda { |...| block } -> a_proc
+ *
+ * Equivalent to Proc.new, except the resulting Proc objects check the
+ * number of parameters passed when called.
+ */
+
+static VALUE
+f_lambda(VALUE _)
+{
+ f_lambda_warn();
return rb_block_lambda();
}