summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--object.c3
-rw-r--r--spec/ruby/core/module/autoload_spec.rb1
-rw-r--r--test/ruby/test_autoload.rb6
-rw-r--r--version.h2
4 files changed, 11 insertions, 1 deletions
diff --git a/object.c b/object.c
index 7928592250..454d35790f 100644
--- a/object.c
+++ b/object.c
@@ -2698,16 +2698,19 @@ rb_mod_const_defined(int argc, VALUE *argv, VALUE mod)
if (!RTEST(recur)) {
if (!rb_const_defined_at(mod, id))
return Qfalse;
+ if (p == pend) return Qtrue;
mod = rb_const_get_at(mod, id);
}
else if (beglen == 0) {
if (!rb_const_defined(mod, id))
return Qfalse;
+ if (p == pend) return Qtrue;
mod = rb_const_get(mod, id);
}
else {
if (!rb_const_defined_from(mod, id))
return Qfalse;
+ if (p == pend) return Qtrue;
mod = rb_const_get_from(mod, id);
}
#endif
diff --git a/spec/ruby/core/module/autoload_spec.rb b/spec/ruby/core/module/autoload_spec.rb
index d6af169cff..ba8132100b 100644
--- a/spec/ruby/core/module/autoload_spec.rb
+++ b/spec/ruby/core/module/autoload_spec.rb
@@ -409,6 +409,7 @@ describe "Module#autoload" do
it "does not load the file when accessing the constants table of the module" do
ModuleSpecs::Autoload.autoload :P, @non_existent
ModuleSpecs::Autoload.const_defined?(:P).should be_true
+ ModuleSpecs::Autoload.const_defined?("P").should be_true
end
it "loads the file when opening a module that is the autoloaded constant" do
diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb
index 8311c40c35..1d2d1af00c 100644
--- a/test/ruby/test_autoload.rb
+++ b/test/ruby/test_autoload.rb
@@ -42,8 +42,10 @@ p Foo::Bar
require 'tmpdir'
Dir.mktmpdir('autoload') {|tmpdir|
tmpfile = tmpdir + '/foo.rb'
+ tmpfile2 = tmpdir + '/bar.rb'
a = Module.new do
autoload :X, tmpfile
+ autoload :Y, tmpfile2
end
b = Module.new do
include a
@@ -52,6 +54,10 @@ p Foo::Bar
assert_equal(true, b.const_defined?(:X))
assert_equal(tmpfile, a.autoload?(:X), bug4565)
assert_equal(tmpfile, b.autoload?(:X), bug4565)
+ assert_equal(true, a.const_defined?("Y"))
+ assert_equal(true, b.const_defined?("Y"))
+ assert_equal(tmpfile2, a.autoload?("Y"))
+ assert_equal(tmpfile2, b.autoload?("Y"))
}
end
diff --git a/version.h b/version.h
index 65491c24ad..d9885ecbea 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.6.6"
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 118
+#define RUBY_PATCHLEVEL 119
#define RUBY_RELEASE_YEAR 2019
#define RUBY_RELEASE_MONTH 12