Backport #8367

regression in defined?(super) starting with 2.0.0-p0

Added by André Arko over 2 years ago. Updated over 2 years ago.

[ruby-core:54769]
Status:Closed
Priority:Normal
Assignee:Tomoyuki Chikanaga

Description

=begin
Hello,

I have discovered a regression in the behaviour of (({defined?(super)})). It functions as expected in 1.9.3-p392, but has changed in 2.0.0-p0 and in 2.1.0dev (2013-05-03 trunk 40571).

On Ruby 1.9.3, the call returns the string (({"super"})). On 2.0.0-p0 and above, the call returns (({nil})). The change seems to be specific to the inside of a block in a method that is defined in a module that is extended onto the object where the method is called.

This is a minimal reproduction example, which I have also attached as "super-gone.rb".

class C
def x; end
end

module M
def b; yield; end

def x
b do
# On 1.9.3, this is "super", but on 2.0.0 it is nil
p defined?(super)
end
end
end

c = C.new
c.extend M
c.x

Thank you.
=end

super-gone.rb Magnifier (491 Bytes) André Arko, 05/04/2013 10:20 AM


Related issues

Related to Ruby trunk - Bug #6644: Weird behavior of defined?(super) check invoked from a metaprogrammatically defined class method Closed 06/25/2012

Associated revisions

Revision 40583
Added by Nobuyoshi Nakada over 2 years ago

insns.def: method entry from method frame

  • insns.def (defined): get method entry from the method top level frame, not block frame. [Bug #8367]

Revision 40613
Added by Tomoyuki Chikanaga over 2 years ago

merge revision(s) 40583,40584,40585,40590: [Backport #8367]

* insns.def (defined): get method entry from the method top level
  frame, not block frame.   [Bug #8367]

* insns.def (defined): use vm_search_superclass() like as normal super
  call.  based on a patch <https://gist.github.com/wanabe/5520026> by
  wanabe.

* vm_insnhelper.c (vm_search_superclass): return error but not raise
  exceptions.

* vm_insnhelper.c (vm_search_super_method): check the result of
  vm_search_superclass and raise execptions on error.
  vm_search_superclass and raise exceptions on error.

History

#1 Updated by Tomoyuki Chikanaga over 2 years ago

  • Assignee set to Nobuyoshi Nakada
  • Category set to core
  • Status changed from Open to Assigned
  • Target version set to 2.1.0
  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: UNKNOWN, 2.0.0: REQUIRED

#2 Updated by Nobuyoshi Nakada over 2 years ago

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

This issue was solved with changeset r40583.
André, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


insns.def: method entry from method frame

  • insns.def (defined): get method entry from the method top level frame, not block frame. [Bug #8367]

#3 Updated by Nobuyoshi Nakada over 2 years ago

  • Target version deleted (2.1.0)
  • Tracker changed from Bug to Backport
  • Project changed from Ruby trunk to Backport200
  • Category deleted (core)
  • Status changed from Closed to Assigned
  • Assignee changed from Nobuyoshi Nakada to Tomoyuki Chikanaga

#4 Updated by Tomoyuki Chikanaga over 2 years ago

Hello,

Should I backport r40584 too?

#5 Updated by Nobuyoshi Nakada over 2 years ago

Probably, yes.

#6 Updated by Tomoyuki Chikanaga over 2 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r40613.
André, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 40583,40584,40585,40590: [Backport #8367]

* insns.def (defined): get method entry from the method top level
  frame, not block frame.   [Bug #8367]

* insns.def (defined): use vm_search_superclass() like as normal super
  call.  based on a patch <https://gist.github.com/wanabe/5520026> by
  wanabe.

* vm_insnhelper.c (vm_search_superclass): return error but not raise
  exceptions.

* vm_insnhelper.c (vm_search_super_method): check the result of
  vm_search_superclass and raise execptions on error.
  vm_search_superclass and raise exceptions on error.

Also available in: Atom PDF