aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/ruby/test_refinement.rb25
-rw-r--r--vm_args.c12
2 files changed, 34 insertions, 3 deletions
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index a178f24591..f6e08729d7 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -1769,6 +1769,31 @@ class TestRefinement < Test::Unit::TestCase
assert_equal("Foo#x", FooExtClient.return_proc(&:x).(Foo.new))
end
+ def test_symbol_proc_with_block
+ assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
+ bug = '[ruby-core:80219] [Bug #13325]'
+ begin;
+ module M
+ refine Class.new do
+ end
+ end
+ class C
+ def call(a, x, &b)
+ b.call(a, &x)
+ end
+ end
+ o = C.new
+ r = nil
+ x = ->(z){r = z}
+ assert_equal(42, o.call(42, x, &:tap))
+ assert_equal(42, r)
+ using M
+ r = nil
+ assert_equal(42, o.call(42, x, &:tap), bug)
+ assert_equal(42, r, bug)
+ end;
+ end
+
module AliasInSubclass
class C
def foo
diff --git a/vm_args.c b/vm_args.c
index 6cded80924..9249984d80 100644
--- a/vm_args.c
+++ b/vm_args.c
@@ -12,6 +12,8 @@ NORETURN(static void raise_argument_error(rb_thread_t *th, const rb_iseq_t *iseq
NORETURN(static void argument_arity_error(rb_thread_t *th, const rb_iseq_t *iseq, const int miss_argc, const int min_argc, const int max_argc));
NORETURN(static void argument_kw_error(rb_thread_t *th, const rb_iseq_t *iseq, const char *error, const VALUE keys));
VALUE rb_keyword_error_new(const char *error, VALUE keys); /* class.c */
+static VALUE method_missing(VALUE obj, ID id, int argc, const VALUE *argv,
+ enum method_missing_reason call_status);
struct args_info {
/* basic args info */
@@ -800,6 +802,7 @@ refine_sym_proc_call(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
VALUE obj;
ID mid;
const rb_callable_method_entry_t *me;
+ rb_thread_t *th;
if (argc-- < 1) {
rb_raise(rb_eArgError, "no receiver given");
@@ -807,11 +810,14 @@ refine_sym_proc_call(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
obj = *argv++;
mid = SYM2ID(callback_arg);
me = rb_callable_method_entry_with_refinements(CLASS_OF(obj), mid);
+ th = GET_THREAD();
+ if (!NIL_P(blockarg)) {
+ vm_passed_block_handler_set(th, blockarg);
+ }
if (!me) {
- /* fallback to funcall (e.g. method_missing) */
- return rb_funcall_with_block(obj, mid, argc, argv, blockarg);
+ return method_missing(obj, mid, argc, argv, MISSING_NOENTRY);
}
- return vm_call0(GET_THREAD(), obj, mid, argc, argv, me);
+ return vm_call0(th, obj, mid, argc, argv, me);
}
static void