diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2019-08-28 18:19:11 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2019-08-29 18:34:09 +0900 |
commit | 7bcfd9189a6a0b2ad58fed988faaf795a4987893 (patch) | |
tree | 219f0c172e038ea6be1e103db11f7457dc703328 /proc.c | |
parent | 7b6fde4258e700c0e0292bb091aa84a5e473342e (diff) |
drop-in type check for rb_define_global_function
We can check the function pointer passed to rb_define_global_function
like we do so in rb_define_method. It turns out that almost anybody
is misunderstanding the API.
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -836,6 +836,12 @@ rb_block_proc(void) return proc_new(rb_cProc, FALSE); } +static VALUE +f_proc(VALUE _) +{ + return rb_block_proc(); +} + /* * call-seq: * lambda { |...| block } -> a_proc @@ -850,6 +856,12 @@ rb_block_lambda(void) return proc_new(rb_cProc, TRUE); } +static VALUE +f_lambda(VALUE _) +{ + return rb_block_lambda(); +} + /* Document-method: Proc#=== * * call-seq: @@ -3623,8 +3635,8 @@ Init_Proc(void) rb_vm_register_special_exception(ruby_error_sysstack, rb_eSysStackError, "stack level too deep"); /* utility functions */ - rb_define_global_function("proc", rb_block_proc, 0); - rb_define_global_function("lambda", rb_block_lambda, 0); + rb_define_global_function("proc", f_proc, 0); + rb_define_global_function("lambda", f_lambda, 0); /* Method */ rb_cMethod = rb_define_class("Method", rb_cObject); |