From: Nobuyoshi@..., Nakada@... Date: 2014-01-11T03:50:37+00:00 Subject: [ruby-core:59692] [ruby-trunk - Bug #9393] (Closed) Strange behavior of DelegateClass + loop + method_missing ������������ #9393 ��� Nobuyoshi Nakada ������������������������������������ ������ ��������� ��������������� ��� Open ������ Closed ��������� Correct behavior. `loop` is also delegated to the target object now. ---------------------------------------- Bug #9393: Strange behavior of DelegateClass + loop + method_missing https://bugs.ruby-lang.org/issues/9393#change-44215 * ���������: Pavel Forkert * ���������������: Closed * ���������: Normal * ���������: * ������������: * ���������������������: * ruby -v: 2.1.0-p0 * Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- Having the following class in Ruby 2.1: ``` require 'delegate' class A < DelegateClass(Hash) def a loop do ::Kernel.p 'A' break end end end ``` After calling `A.new({}).a` the output is "A". However if `method_missing` is added to the class: ``` class A < DelegateClass(Hash) def a loop do ::Kernel.p 'A' break end end def method_missing(method, *args, &block) ::Kernel.p method end end ``` Then after calling `A.new({}).a`, the output is somewhat unexpected: `:loop`. That actually means that `:loop` method cannot be found and the block within the loop will not run. Is that the right behavior? Ruby 2.0 returns "A" in both cases. -- http://bugs.ruby-lang.org/