diff options
author | Nobuyoshi Nakada <[email protected]> | 2020-02-22 00:32:43 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2020-02-22 00:45:05 +0900 |
commit | 8c5ca318cbe57269f144a4d0822c5283c1fd4e1a (patch) | |
tree | 8affdb4955703701e4b9ee9bf0ed6bc0c42da5a3 | |
parent | 5cab86f3b0725457be3c50d3cab43b04bea53290 (diff) |
`Proc` made by `Symbol#to_proc` should be a lambda [Bug #16260]
With refinements, too.
-rw-r--r-- | internal/proc.h | 2 | ||||
-rw-r--r-- | proc.c | 2 | ||||
-rw-r--r-- | test/ruby/test_symbol.rb | 7 | ||||
-rw-r--r-- | vm_args.c | 2 |
4 files changed, 10 insertions, 3 deletions
diff --git a/internal/proc.h b/internal/proc.h index 7f2bec8850..864392906b 100644 --- a/internal/proc.h +++ b/internal/proc.h @@ -19,11 +19,11 @@ VALUE rb_proc_location(VALUE self); st_index_t rb_hash_proc(st_index_t hash, VALUE proc); int rb_block_arity(void); int rb_block_min_max_arity(int *max); -VALUE rb_func_lambda_new(rb_block_call_func_t func, VALUE val, int min_argc, int max_argc); VALUE rb_block_to_s(VALUE self, const struct rb_block *block, const char *additional_info); MJIT_SYMBOL_EXPORT_BEGIN VALUE rb_func_proc_new(rb_block_call_func_t func, VALUE val); +VALUE rb_func_lambda_new(rb_block_call_func_t func, VALUE val, int min_argc, int max_argc); VALUE rb_iseq_location(const struct rb_iseq_struct *iseq); VALUE rb_sym_to_proc(VALUE sym); MJIT_SYMBOL_EXPORT_END @@ -739,7 +739,7 @@ rb_func_proc_new(rb_block_call_func_t func, VALUE val) return cfunc_proc_new(rb_cProc, (VALUE)ifunc, 0); } -VALUE +MJIT_FUNC_EXPORTED VALUE rb_func_lambda_new(rb_block_call_func_t func, VALUE val, int min_argc, int max_argc) { struct vm_ifunc *ifunc = rb_vm_ifunc_new(func, (void *)val, min_argc, max_argc); diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb index 2e9710e4dc..632acb3e3d 100644 --- a/test/ruby/test_symbol.rb +++ b/test/ruby/test_symbol.rb @@ -169,6 +169,9 @@ class TestSymbol < Test::Unit::TestCase def _test_to_proc_arg_with_refinements_call(&block) block.call TestToPRocArgWithRefinements.new end + def _test_to_proc_with_refinements_call(&block) + block + end using Module.new { refine TestToPRocArgWithRefinements do def hoge @@ -180,6 +183,10 @@ class TestSymbol < Test::Unit::TestCase assert_equal(:hoge, _test_to_proc_arg_with_refinements_call(&:hoge)) end + def test_to_proc_lambda_with_refinements + assert_predicate(_test_to_proc_with_refinements_call(&:hoge), :lambda?) + end + def self._test_to_proc_arg_with_refinements_call(&block) block.call TestToPRocArgWithRefinements.new end @@ -869,7 +869,7 @@ vm_caller_setup_arg_block(const rb_execution_context_t *ec, rb_control_frame_t * rb_ary_push(callback_arg, block_code); rb_ary_push(callback_arg, ref); OBJ_FREEZE_RAW(callback_arg); - func = rb_func_proc_new(refine_sym_proc_call, callback_arg); + func = rb_func_lambda_new(refine_sym_proc_call, callback_arg, 0, UNLIMITED_ARGUMENTS); rb_hash_aset(ref, block_code, func); } block_code = func; |