[ruby-cvs:78649] 55b7ba3686 (master): Make super in instance_eval in method in module raise TypeError

"Jeremy Evans" <[email protected]>
Newsgroups gmane.comp.lang.ruby.cvs
Message-ID <[email protected]>
Jeremy Evans	2019-08-22 05:59:36 +0900 (Thu, 22 Aug 2019)

  New Revision: 55b7ba3686

  https://github.com/ruby/ruby/commit/55b7ba3686

  Log:
    Make super in instance_eval in method in module raise TypeError
    
    This makes behavior the same as super in instance_eval in method
    in class.  The reason this wasn't implemented before is that
    there is a check to determine if the self in the current context
    is of the expected class, and a module itself can be included
    in multiple classes, so it doesn't have an expected class.
    
    Implementing this requires giving iclasses knowledge of which
    class created them, so that super call in the module method
    knows the expected class for super calls.  This reference
    is called includer, and should only be set for iclasses.
    
    Note that the approach Ruby uses in this check is not robust. If
    you instance_eval another object of the same class and call super,
    instead of an TypeError, you get super called with the
    instance_eval receiver instead of the method receiver.  Truly
    fixing super would require keeping a reference to the super object
    (method receiver) in each frame where scope has changed, and using
    that instead of current self when calling super.
    
    Fixes [Bug #11636]

  Modified files:
    class.c
    internal.h
    test/ruby/test_super.rb
    vm_insnhelper.c
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.