diff options
author | Jeremy Evans <[email protected]> | 2020-06-10 17:50:35 -0700 |
---|---|---|
committer | Jeremy Evans <[email protected]> | 2020-06-11 07:30:48 -0700 |
commit | 2188d6d160d3ba82432c87277310a4d417e136d5 (patch) | |
tree | f885cb534dc38c06db3431076719436563f96fb9 /proc.c | |
parent | 5349506eb4c0668fa1d6f512e4dae1021a9a7460 (diff) |
Warn when passing a non-literal block to Kernel#lambda
Implements [Feature #15973]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3209
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -855,6 +855,19 @@ rb_block_lambda(void) static VALUE f_lambda(VALUE _) { + VALUE block_handler = rb_vm_frame_block_handler(GET_EC()->cfp); + + if (block_handler != VM_BLOCK_HANDLER_NONE) { + switch (vm_block_handler_type(block_handler)) { + case block_handler_type_proc: + case block_handler_type_symbol: + case block_handler_type_ifunc: + rb_warn_deprecated("lambda without a literal block", "the proc without lambda"); + default: + break; + } + } + return rb_block_lambda(); } |