ruby-changes:50447
From: naruse <ko1@a...>
Date: Sun, 25 Feb 2018 09:36:49 +0900 (JST)
Subject: [ruby-changes:50447] naruse:r62568 (ruby_2_5): merge revision(s) 62071: [Backport #14407]
naruse 2018-02-25 09:36:43 +0900 (Sun, 25 Feb 2018) New Revision: 62568 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62568 Log: merge revision(s) 62071: [Backport #14407] defined? returns nil for toplevel constant lookup * variable.c (rb_const_defined_0): toplevel constant lookup has been removed, should return nil too. [ruby-core:85142] [Bug #14407] [Fix GH-1800] From: Gonzalo <grzuy0@g...> Modified directories: branches/ruby_2_5/ Modified files: branches/ruby_2_5/spec/ruby/language/defined_spec.rb branches/ruby_2_5/test/ruby/test_defined.rb branches/ruby_2_5/variable.c branches/ruby_2_5/version.h Index: ruby_2_5/test/ruby/test_defined.rb =================================================================== --- ruby_2_5/test/ruby/test_defined.rb (revision 62567) +++ ruby_2_5/test/ruby/test_defined.rb (revision 62568) @@ -253,4 +253,8 @@ class TestDefined < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_5/test/ruby/test_defined.rb#L253 assert_equal(nil, obj.func_defined_non_existing_func, bug_11212) assert_equal(true, obj.called, bug_11212) end + + def test_top_level_constant_not_defined + assert_nil(defined?(TestDefined::Object)) + end end Index: ruby_2_5/spec/ruby/language/defined_spec.rb =================================================================== --- ruby_2_5/spec/ruby/language/defined_spec.rb (revision 62567) +++ ruby_2_5/spec/ruby/language/defined_spec.rb (revision 62568) @@ -766,8 +766,8 @@ describe "The defined? keyword for a sco https://github.com/ruby/ruby/blob/trunk/ruby_2_5/spec/ruby/language/defined_spec.rb#L766 defined?(DefinedSpecs::String).should be_nil end - it "returns 'constant' when a constant is defined on top-level but not on the class" do - defined?(DefinedSpecs::Basic::String).should == "constant" + it "returns nil when a constant is defined on top-level but not on the class" do + defined?(DefinedSpecs::Basic::String).should be_nil end it "returns 'constant' if the scoped-scoped constant is defined" do Index: ruby_2_5/variable.c =================================================================== --- ruby_2_5/variable.c (revision 62567) +++ ruby_2_5/variable.c (revision 62568) @@ -2515,6 +2515,11 @@ rb_const_defined_0(VALUE klass, ID id, i https://github.com/ruby/ruby/blob/trunk/ruby_2_5/variable.c#L2515 if (ce->value == Qundef && !check_autoload_required(tmp, id, 0) && !rb_autoloading_value(tmp, id, 0)) return (int)Qfalse; + + if (exclude && tmp == rb_cObject && klass != rb_cObject) { + return (int)Qfalse; + } + return (int)Qtrue; } if (!recurse) break; Index: ruby_2_5/version.h =================================================================== --- ruby_2_5/version.h (revision 62567) +++ ruby_2_5/version.h (revision 62568) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_5/version.h#L1 #define RUBY_VERSION "2.5.0" #define RUBY_RELEASE_DATE "2018-02-24" -#define RUBY_PATCHLEVEL 35 +#define RUBY_PATCHLEVEL 36 #define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_MONTH 2 Index: ruby_2_5 =================================================================== --- ruby_2_5 (revision 62567) +++ ruby_2_5 (revision 62568) Property changes on: ruby_2_5 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r62071 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/