From: "alexisowl (Alexey Smolianinov)" Date: 2012-07-11T19:59:25+09:00 Subject: [ruby-core:46322] [ruby-trunk - Bug #6722][Open] Weird behavior of defined?(super) check invoked from a metaprogrammatically defined class method Issue #6722 has been reported by alexisowl (Alexey Smolianinov). ---------------------------------------- Bug #6722: Weird behavior of defined?(super) check invoked from a metaprogrammatically defined class method https://bugs.ruby-lang.org/issues/6722 Author: alexisowl (Alexey Smolianinov) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.3p0 (2011-10-30 revision 33570) [i686-linux] =begin Hi guys, Sorry for the duplicate - I already reported (()) 2 weeks ago, but didn't receive any answer. I had mistakenly assigned "target version", maybe that was the reason of no response? Please let me know if my bug report is wrong or irrelevant in any other respect. Here's a link to the discussion of the issue on stackoverflow: (()) Bellow is my initial description: -- Lately I came across some weird behavior with the (({defined?})) operator used to check if (({super})) keyword can be invoked in current context. Usually it works fine, but when I tried to combine the (({defined? super})) check with a tiny bit of metaprogramming, it gave me unexpected results. class A; def self.def_f!; singleton_class.send(:define_method, :f) { defined? super } end end class AA < A; end A.def_f! A.f # => nil AA.f # => nil AA.def_f! AA.f # => "super" A.f # => "super" - WHY??? The last result is really strange, isn't it? (({A.f})) has no super method, so I would expect the last (({A.f})) to return (({nil})). =end -- http://bugs.ruby-lang.org/