From: alxtskrnk@... Date: 2016-10-24T21:44:54+00:00 Subject: [ruby-core:77755] [Ruby trunk Feature#12861] super in a block can be either lexically or dynamically scoped depending on how the block is invoked Issue #12861 has been updated by bug hit. super is in sync with __method__ because they are designed to be in sync, __method__ called from a block typically returns the enclosing method of the block but not always, when the block is invoked as a method, __super__ returns the method represented by the block. This arguments does not alter the fact that super called from a block is usually lexically bound to the enclosing method but not always. I think that's not ideal, something as significant as lexical vs dynamic binding should be fixed for a given concept/construct. ---------------------------------------- Feature #12861: super in a block can be either lexically or dynamically scoped depending on how the block is invoked https://bugs.ruby-lang.org/issues/12861#change-61058 * Author: bug hit * Status: Open * Priority: Normal * Assignee: Yukihiro Matsumoto ---------------------------------------- ```ruby class Class1 def self.foo 'foo' end def self.method1 'method1' end end class Class2 < Class1 def self.foo bar do super() end end def self.bar(&block) a = block.() define_singleton_method :method1, &block b = send(:method1) c = block.() [a, b, c] end end p Class2.foo # ["foo", "method1", "foo"] ``` It doesn't seem like a good idea for a given language construct to be either lexically or dynamically scoped, depending on how its surrounding block is invoked (which is not visible at the point of definition). I think it would be better if super were always lexically scoped, and a different keyword (dynamic_super) were always dynamically scoped -- https://bugs.ruby-lang.org/ Unsubscribe: