This project is closed and read-only.
Actions
Bug #2600
closedblock.callの中でsuperできない
Bug #2600:
block.callの中でsuperできない
Description
=begin
須藤です。
r25975の変更
- eval.c (proc_invoke): unbound block created by define_method
cannot call super. [ruby-core:26984]
から、以下のようにすると
NoMethodError: super called outside of method
という例外が発生するようになりました。
class Parent
def run
:parent_run
end
end
class Child < Parent
def run
callback do
super
end
end
end
Child.new.run # -> 例外
Child#callbackの中のblock.callをyieldにすると例外は起きなく
なります。
SubjectにBugをつけてしまったのですが、そもそもこれはBugではな
く意図した変更なのでしょうか?
とりあえず、テストケースは添付しておきます。
余談ですが、この間リリースされたRuby 1.8.7にもこの変更が入っ
ていたため、Rabbitが動かなくなり、この違いに気づきました。
Index: test/ruby/test_super.rb¶
--- test/ruby/test_super.rb (revision 26302)
+++ test/ruby/test_super.rb (working copy)
@@ -149,4 +149,26 @@
c = C.new
assert_equal([c, "#{C.to_s}::m"], c.m, bug2419)
end
+
- class Parent
- def run
- end
- end
- class Child < Parent
- def run
- end
- def callback(&block)
- end
- end
- def test_super_in_block_call
- assert_equal(:parent_run, Child.new.run)
- end
end
=end
Actions