diff options
author | Koichi Sasada <[email protected]> | 2020-12-12 06:29:11 +0900 |
---|---|---|
committer | Koichi Sasada <[email protected]> | 2020-12-12 06:29:11 +0900 |
commit | 124321e0c7ab8dac1ffce78c653cc677f878d5b0 (patch) | |
tree | 53be2cc7989b0392b57ca78afb03b9c4fc9b2b0d /proc.c | |
parent | d741c77b5fd976300815c1ea987e76e92b71122f (diff) |
fix lambda's warning and tests
There are warning condition bugs and test bugs.
b53ccb9c69abd24e3bdad66cbe4c7e7480eaef16
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 36 |
1 files changed, 22 insertions, 14 deletions
@@ -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(); } |