Project

General

Profile

Bug #11117

When you refine String with to_regexp, then it breaks Regexp.try_convert even when the refinement is not used

Added by jirutka (Jakub Jirutka) over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
2.2.2p95
[ruby-core:69064]

Description

I’ve run into a very strange bug with refinements. Let me show you:

module Ref
  refine String do
    def to_regexp
    end
  end
end

Regexp.try_convert('foo')
# or Regexp.union('foo', 'bar')
bug.rb:8:in `try_convert': undefined method `to_regexp' for "foo":String (NoMethodError)
    from test.rb:8:in `<main>'

Note that the refinement is not used (using), only declared, and yet it has affected behaviour of the refined class! This problem occurs only when the method is named to_string. It seems that there’s some serious scoping issue with refinements.

I’ve reproduced this issue on MRI 2.2.2p95, 2.1.5p273, and 2.0.0p598.

Associated revisions

Revision a870f4fc
Added by nobu (Nobuyoshi Nakada) over 4 years ago

vm_eval.c: undefined refined check_funcall

  • vm_eval.c (rb_method_call_status): undefined refined method is not callable unless using. [ruby-core:69064] [Bug #11117]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 50430
Added by nobu (Nobuyoshi Nakada) over 4 years ago

vm_eval.c: undefined refined check_funcall

  • vm_eval.c (rb_method_call_status): undefined refined method is not callable unless using. [ruby-core:69064] [Bug #11117]

Revision 50430
Added by nobu (Nobuyoshi Nakada) over 4 years ago

vm_eval.c: undefined refined check_funcall

  • vm_eval.c (rb_method_call_status): undefined refined method is not callable unless using. [ruby-core:69064] [Bug #11117]

Revision 50430
Added by nobu (Nobuyoshi Nakada) over 4 years ago

vm_eval.c: undefined refined check_funcall

  • vm_eval.c (rb_method_call_status): undefined refined method is not callable unless using. [ruby-core:69064] [Bug #11117]

Revision 50430
Added by nobu (Nobuyoshi Nakada) over 4 years ago

vm_eval.c: undefined refined check_funcall

  • vm_eval.c (rb_method_call_status): undefined refined method is not callable unless using. [ruby-core:69064] [Bug #11117]

Revision 50430
Added by nobu (Nobuyoshi Nakada) over 4 years ago

vm_eval.c: undefined refined check_funcall

  • vm_eval.c (rb_method_call_status): undefined refined method is not callable unless using. [ruby-core:69064] [Bug #11117]

Revision bd872a54
Added by nobu (Nobuyoshi Nakada) over 4 years ago

vm_eval.c: resolve refined method entry

  • vm_eval.c (rb_method_call_status): resolve refined method entry to check if undefined. [ruby-core:69064] [Bug #11117]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 50440
Added by nobu (Nobuyoshi Nakada) over 4 years ago

vm_eval.c: resolve refined method entry

  • vm_eval.c (rb_method_call_status): resolve refined method entry to check if undefined. [ruby-core:69064] [Bug #11117]

Revision 50440
Added by nobu (Nobuyoshi Nakada) over 4 years ago

vm_eval.c: resolve refined method entry

  • vm_eval.c (rb_method_call_status): resolve refined method entry to check if undefined. [ruby-core:69064] [Bug #11117]

Revision 50440
Added by nobu (Nobuyoshi Nakada) over 4 years ago

vm_eval.c: resolve refined method entry

  • vm_eval.c (rb_method_call_status): resolve refined method entry to check if undefined. [ruby-core:69064] [Bug #11117]

Revision 50440
Added by nobu (Nobuyoshi Nakada) over 4 years ago

vm_eval.c: resolve refined method entry

  • vm_eval.c (rb_method_call_status): resolve refined method entry to check if undefined. [ruby-core:69064] [Bug #11117]

Revision 50440
Added by nobu (Nobuyoshi Nakada) over 4 years ago

vm_eval.c: resolve refined method entry

  • vm_eval.c (rb_method_call_status): resolve refined method entry to check if undefined. [ruby-core:69064] [Bug #11117]

Revision 1bd36e36
Added by usa (Usaku NAKAMURA) over 4 years ago

merge revision(s) 50430,50440: [Backport #11117]

    * vm_eval.c (rb_method_call_status): undefined refined method is
      not callable unless using.  [ruby-core:69064] [Bug #11117]

    * vm_eval.c (rb_method_call_status): resolve refined method entry
      to check if undefined.  [ruby-core:69064] [Bug #11117]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@51119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 51119
Added by usa (Usaku NAKAMURA) over 4 years ago

merge revision(s) 50430,50440: [Backport #11117]

* vm_eval.c (rb_method_call_status): undefined refined method is
  not callable unless using.  [ruby-core:69064] [Bug #11117]

* vm_eval.c (rb_method_call_status): resolve refined method entry
  to check if undefined.  [ruby-core:69064] [Bug #11117]

Revision 8ff3a728
Added by nagachika (Tomoyuki Chikanaga) over 4 years ago

merge revision(s) 50430,50440: [Backport #11117]

    * vm_eval.c (rb_method_call_status): undefined refined method is
      not callable unless using.  [ruby-core:69064] [Bug #11117]

    * vm_eval.c (rb_method_call_status): resolve refined method entry
      to check if undefined.  [ruby-core:69064] [Bug #11117]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@51133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 51133
Added by nagachika (Tomoyuki Chikanaga) over 4 years ago

merge revision(s) 50430,50440: [Backport #11117]

* vm_eval.c (rb_method_call_status): undefined refined method is
  not callable unless using.  [ruby-core:69064] [Bug #11117]

* vm_eval.c (rb_method_call_status): resolve refined method entry
  to check if undefined.  [ruby-core:69064] [Bug #11117]

History

#1

Updated by nobu (Nobuyoshi Nakada) over 4 years ago

  • Status changed from Open to Closed

Applied in changeset r50430.


vm_eval.c: undefined refined check_funcall

  • vm_eval.c (rb_method_call_status): undefined refined method is not callable unless using. [ruby-core:69064] [Bug #11117]

Updated by nobu (Nobuyoshi Nakada) over 4 years ago

  • Priority changed from 5 to Normal
  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED

Updated by usa (Usaku NAKAMURA) over 4 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED to 2.0.0: REQUIRED, 2.1: DONE, 2.2: REQUIRED

ruby_2_1 r51119 merged revision(s) 50430,50440.

Updated by nagachika (Tomoyuki Chikanaga) over 4 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: DONE, 2.2: REQUIRED to 2.0.0: REQUIRED, 2.1: DONE, 2.2: DONE

Backported into ruby_2_2 branch at r51133.

Also available in: Atom PDF