ruby-changes:19131
From: nobu <ko1@a...>
Date: Thu, 24 Mar 2011 23:06:51 +0900 (JST)
Subject: [ruby-changes:19131] Ruby:r31170 (trunk): * vm_insnhelper.c (vm_get_ev_const): should not autoload in
nobu 2011-03-24 23:06:31 +0900 (Thu, 24 Mar 2011) New Revision: 31170 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31170 Log: * vm_insnhelper.c (vm_get_ev_const): should not autoload in defined? mode. Modified files: trunk/ChangeLog trunk/test/ruby/test_defined.rb trunk/vm_insnhelper.c Index: ChangeLog =================================================================== --- ChangeLog (revision 31169) +++ ChangeLog (revision 31170) @@ -1,5 +1,8 @@ -Thu Mar 24 23:05:42 2011 Nobuyoshi Nakada <nobu@r...> +Thu Mar 24 23:06:29 2011 Nobuyoshi Nakada <nobu@r...> + * vm_insnhelper.c (vm_get_ev_const): should not autoload in + defined? mode. + * variable.c (rb_const_defined_0): fix autoloading base. [ruby-core:35509] Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 31169) +++ vm_insnhelper.c (revision 31170) @@ -1177,6 +1177,7 @@ if (val == Qundef) { if (am == klass) break; am = klass; + if (is_defined) return 1; rb_autoload_load(klass, id); goto search_continue; } Index: test/ruby/test_defined.rb =================================================================== --- test/ruby/test_defined.rb (revision 31169) +++ test/ruby/test_defined.rb (revision 31170) @@ -103,4 +103,15 @@ end assert_equal("constant", klass.new.a?, bug) end + + def test_autoloaded_noload + klass = Class.new do + autoload(:A, "a") + def a? + defined?(A) + end + end + x = klass.new + assert_equal("constant", x.a?) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/