Project

General

Profile

Bug #2171

Kernel#respond_to_missing? Invoked for Unimplemented Methods

Added by runpaint (Run Paint Run Run) almost 11 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
ruby -v:
ruby 1.9.2dev (2009-10-01 trunk 25173) [i686-linux]
Backport:
[ruby-core:25909]

Description

=begin
Kernel#respond_to_missing? is called for methods that raise NotImplementedError, despite such methods not invoking #method_missing. I expected it not to be.

$ cat /tmp/notimp.rb
[:method_missing, :respond_to_missing?].each do |m|
File.define_singleton_method(m, ->(_){ p m; false })
end
[:glark, :lchmod].each do |m|
puts "<<#{m}>>"
File.respond_to?(m)
File.send(m)
end

$ ruby /tmp/notimp.rb
<>
:respond_to_missing?
:method_missing
<>
:respond_to_missing?
/tmp/notimp.rb:7:in lchmod': lchmod() function is unimplemented on this machine (NotImplementedError)
from /tmp/notimp.rb:7:in
block in '
from /tmp/notimp.rb:4:in each'
from /tmp/notimp.rb:4:in
'
=end

#1

Updated by matz (Yukihiro Matsumoto) almost 11 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r25234.
=end

#2

Updated by nlugovoi (Nikolai Lugovoi) over 10 years ago

=begin
This update introduced some strange/broken behaviour of RSS parser -- test/rss/ were severely failing.

I had to use following patch to restore its work:

diff --git a/vm_method.c b/vm_method.c
index a31fb8b..22b4700 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -512,7 +512,7 @@ rb_method_boundp(VALUE klass, ID id, int ex)
rb_method_entry_t *me = rb_method_entry(klass, id);

  if (me != 0) {
  • if (ex && (me->flag & NOEX_PRIVATE)) {
  • if ((ex & NOEX_PRIVATE) && (me->flag & NOEX_PRIVATE)) {
    return FALSE;
    }
    if (!me->def) return 0;
    @@ -1153,7 +1153,7 @@ basic_obj_respond_to(VALUE obj, ID id, int pub)
    {
    VALUE klass = CLASS_OF(obj);

  • switch (rb_method_boundp(klass, id, pub|NOEX_RESPONDS)) {

  • switch (rb_method_boundp(klass, id, (pub & 0x7F) |NOEX_RESPONDS)) {
    case 2:
    return FALSE;
    case 0:

=end

#3

Updated by nlugovoi (Nikolai Lugovoi) over 10 years ago

=begin
Actually, i pasted wrong patch in previous message.

This one is working and does not break as much -- using (ex & 0x7F):

--- a/vm_method.c
+++ b/vm_method.c
@@ -512,7 +512,7 @@ rb_method_boundp(VALUE klass, ID id, int ex)
rb_method_entry_t *me = rb_method_entry(klass, id);

  if (me != 0) {
  • if (ex && (me->flag & NOEX_PRIVATE)) {
  • if ((ex & 0x7f) && (me->flag & NOEX_PRIVATE)) {
    return FALSE;
    }
    if (!me->def) return 0;
    @@ -1153,7 +1153,7 @@ basic_obj_respond_to(VALUE obj, ID id, int pub)
    {
    VALUE klass = CLASS_OF(obj);

  • switch (rb_method_boundp(klass, id, pub|NOEX_RESPONDS)) {

  • switch (rb_method_boundp(klass, id, (pub & 0x7F)|NOEX_RESPONDS)) {
    case 2:
    return FALSE;
    case 0:

=end

#4

Updated by marcandre (Marc-Andre Lafortune) over 10 years ago

  • Status changed from Closed to Open
  • Priority changed from 3 to Normal

=begin

=end

#5

Updated by marcandre (Marc-Andre Lafortune) over 10 years ago

  • Status changed from Open to Closed

=begin

=end

Also available in: Atom PDF