Project

General

Profile

Actions

Bug #2945

closed

Regexp#=== is failed by an exception when the exception is occurred in method_missing

Added by mrkn (Kenta Murata) over 14 years ago. Updated over 13 years ago.

Status:
Rejected
Assignee:
-
Target version:
ruby -v:
ruby 1.9.2dev (2010-03-08 trunk 26849) [x86_64-darwin10.2.0]
Backport:
[ruby-core:28552]

Description

=begin
When an exception is occurred in method_missing,
Regexp#=== is failed by the exception.
Is this valid behavior?

o = Object.new
class <<
def method_missing(m, *args)
raise "XXX" if m == :to_str
end
end
/aaa/ === o # =:> `method_missing': XXX (RuntimeError)

If correct this, apply the following patch.

diff --git a/re.c b/re.c
index 6ec3646..8a38155 100644
--- a/re.c
+++ b/re.c
@@ -2685,6 +2685,12 @@ rb_reg_match(VALUE re, VALUE str)
return LONG2FIX(pos);
}

+static VALUE
+reg_check_operand(VALUE str)
+{

  • return reg_operand(str, FALSE);
    +}

/*

  • call-seq:
  • rxp === str   => true or false
    

@@ -2708,7 +2714,7 @@ rb_reg_eqq(VALUE re, VALUE str)
{
long start;

  • str = reg_operand(str, FALSE);
  • str = rb_protect(reg_check_operand, str, 0);
    if (NIL_P(str)) {
    rb_backref_set(Qnil);
    return Qfalse;
    =end
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0