[#37050] [Feature #735] Date#inspect — "rubikitch ." <redmine@...>

Feature #735: Date#inspect

14 messages 2008/11/09

[#37075] [Feature #747] /\A/u ignores BOM — Shyouhei Urabe <redmine@...>

Feature #747: /\A/u ignores BOM

14 messages 2008/11/12

[#37161] m17n of irb — "Yugui (Yuki Sonoda)" <yugui@...>

Yuguiです。

35 messages 2008/11/24
[#37183] Re: m17n of irb — keiju@... (keiju ISHITSUKA) 2008/11/25

けいじゅ@いしつかです.

[#37203] Re: m17n of irb — "Yugui (Yuki Sonoda)" <yugui@...> 2008/11/26

keiju ISHITSUKA さんは書きました:

[#37292] Re: m17n of irb — Yukihiro Matsumoto <matz@...> 2008/12/06

まつもと ゆきひろです

[#37293] Re: m17n of irb — "Yugui (Yuki Sonoda)" <yugui@...> 2008/12/07

Yuguiです。

[#37298] Re: m17n of irb — Yukihiro Matsumoto <matz@...> 2008/12/07

まつもと ゆきひろです

[#37210] RSS::Maker.create(version) — "Akinori MUSHA" <knu@...>

 RSS::Maker で、 "2.0" 等の文字列でフィードのフォーマットを渡す

15 messages 2008/11/27

[#37213] Re: [ruby-cvs:27586] Ruby:r20368 (trunk): * ext/bigdecimal/bigdecimal.c (BigDecimal_div2): should return — Tadayoshi Funaba <tadf@...>

> * ext/bigdecimal/bigdecimal.c (BigDecimal_div2): should return

8 messages 2008/11/27

[ruby-dev:37147] Re: super dynamic class definition causes infinite loop

From: Kouhei Sutou <kou@...>
Date: 2008-11-23 04:32:08 UTC
List: ruby-dev #37147
須藤です。

In <20081109.133949.475793127247145680.kou@cozmixng.org>
  "[ruby-dev:37045] super dynamic class definition causes infinite loop" on Sun, 9 Nov 2008 13:37:39 +0900,
  Kouhei Sutou <kou@cozmixng.org> wrote:

> 以下のスクリプトの2回目のdefined_class.newで無限ループになっ
> てしまいます。
> 
> ---
> def define_class(parent=nil)
>   Class.new(parent || Object) do
>     def initialize
>       super
>     end
>   end
> end
> 
> defined_class = define_class
> p defined_class.new
> 
> define_class(defined_class)
> p defined_class.new
> ---
> 
> % /tmp/local/bin/ruby -v /tmp/a.rb
> ruby 1.9.0 (2008-11-09 revision 20163) [x86_64-linux]
> #<#<Class:0x00000000ef6c30>:0x00000000ef6640>
> /tmp/a.rb:4:in `initialize': stack level too deep (SystemStackError)
> 	from /tmp/a.rb:4:in `initialize'
> 	from /tmp/a.rb:4:in `initialize'
> 	from /tmp/a.rb:4:in `initialize'
> 	from /tmp/a.rb:4:in `initialize'
> 	from /tmp/a.rb:4:in `initialize'
> 	from /tmp/a.rb:4:in `initialize'
> 	from /tmp/a.rb:4:in `initialize'
> 	from /tmp/a.rb:4:in `initialize'
> 	 ... 8716 levels...
> 	from /tmp/a.rb:4:in `initialize'
> 	from /tmp/a.rb:4:in `initialize'
> 	from /tmp/a.rb:13:in `new'
> 	from /tmp/a.rb:13:in `<main>'

テストにしてみました。


Index: test/ruby/test_class.rb
===================================================================
--- test/ruby/test_class.rb	(revision 20332)
+++ test/ruby/test_class.rb	(working copy)
@@ -144,4 +144,20 @@
     assert_raise(TypeError) { Class.allocate.new }
     assert_raise(TypeError) { Class.allocate.superclass }
   end
+
+  def test_dynamic_defined_initialize
+    define_class = Proc.new do |parent|
+      Class.new(parent) do
+        def initialize
+          super
+        end
+      end
+    end
+
+    defined_class = define_class.call(Object)
+    assert_nothing_raised {defined_class.new}
+
+    define_class.call(defined_class)
+    assert_nothing_raised {defined_class.new}
+  end
 end

このように失敗します。

% ./ruby test/runner.rb -ntest_dynamic_defined_initialize test/ruby/test_class.rb
Loaded suite test/runner
Started
F
Finished in 0.046818 seconds.

  1) Failure:
test_dynamic_defined_initialize(TestClass) [/home/kou/work/ruby/ruby/test/ruby/test_class.rb:152]:
Exception raised:
<#<SystemStackError: stack level too deep>>.

1 tests, 0 assertions, 1 failures, 0 errors, 0 skips

In This Thread

Prev Next