summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorcharliesome <charliesome@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-07 06:44:31 +0000
committercharliesome <charliesome@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-07 06:44:31 +0000
commit66915c507777c5e3a978fa73de25db763efd9206 (patch)
tree4cd361c3844135e2a83afc72449325af4d8d8b1a /vm_insnhelper.c
parentc65e9bbff91ce0158aecd17b5a94b6fdafbd4238 (diff)
* vm_eval.c (vm_call0): fix prototype, the id parameter should be of
type ID, not VALUE * vm_insnhelper.c (check_match): the rb_funcall family of functions does not care about refinements. We need to use rb_method_entry_with_refinements instead to call === with refinements. Thanks to Jon Conley for reporting this bug. [ruby-core:57051] [Bug #8872] * test/ruby/test_refinement.rb: add test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 545b45e034..dd6f26bdc5 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -931,18 +931,23 @@ rb_equal_opt(VALUE obj1, VALUE obj2)
}
static VALUE
+vm_call0(rb_thread_t*, VALUE, ID, int, const VALUE*, const rb_method_entry_t*, VALUE);
+
+static VALUE
check_match(VALUE pattern, VALUE target, enum vm_check_match_type type)
{
switch (type) {
case VM_CHECKMATCH_TYPE_WHEN:
return pattern;
- case VM_CHECKMATCH_TYPE_CASE:
- return rb_funcall2(pattern, idEqq, 1, &target);
- case VM_CHECKMATCH_TYPE_RESCUE: {
+ case VM_CHECKMATCH_TYPE_RESCUE:
if (!rb_obj_is_kind_of(pattern, rb_cModule)) {
rb_raise(rb_eTypeError, "class or module required for rescue clause");
}
- return RTEST(rb_funcall2(pattern, idEqq, 1, &target));
+ /* fall through */
+ case VM_CHECKMATCH_TYPE_CASE: {
+ VALUE defined_class;
+ rb_method_entry_t *me = rb_method_entry_with_refinements(CLASS_OF(pattern), idEqq, &defined_class);
+ return vm_call0(GET_THREAD(), pattern, idEqq, 1, &target, me, defined_class);
}
default:
rb_bug("check_match: unreachable");