summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--ext/-test-/path_to_class/extconf.rb6
-rw-r--r--ext/-test-/path_to_class/path_to_class.c9
-rw-r--r--test/-ext-/path_to_class/test_path_to_class.rb12
-rw-r--r--variable.c2
5 files changed, 34 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 0d6640c55b..6216982312 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Nov 30 23:35:45 2011 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * variable.c (rb_path2class): don't raise NameError when the middle
+ constant of the path is not defined but defined on toplevel.
+ [ruby-core:41410] [Bug #5691]
+
Wed Nov 30 20:02:02 2011 Martin Duerst <duerst@it.aoyama.ac.jp>
* transcode.c: Simplified rb_econv_binmode, avoided a warning on cygwin.
diff --git a/ext/-test-/path_to_class/extconf.rb b/ext/-test-/path_to_class/extconf.rb
new file mode 100644
index 0000000000..e1072b1443
--- /dev/null
+++ b/ext/-test-/path_to_class/extconf.rb
@@ -0,0 +1,6 @@
+$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+inits = $srcs.map {|s| File.basename(s, ".*")}
+inits.delete("init")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+create_makefile("-test-/path_to_class/path_to_class")
diff --git a/ext/-test-/path_to_class/path_to_class.c b/ext/-test-/path_to_class/path_to_class.c
new file mode 100644
index 0000000000..9b88b48d40
--- /dev/null
+++ b/ext/-test-/path_to_class/path_to_class.c
@@ -0,0 +1,9 @@
+#include "ruby.h"
+
+void
+Init_path_to_class(void)
+{
+ VALUE klass = rb_path2class("Test_PathToClass");
+
+ rb_define_singleton_method(klass, "path_to_class", rb_path_to_class, 1);
+}
diff --git a/test/-ext-/path_to_class/test_path_to_class.rb b/test/-ext-/path_to_class/test_path_to_class.rb
new file mode 100644
index 0000000000..fdf4097fde
--- /dev/null
+++ b/test/-ext-/path_to_class/test_path_to_class.rb
@@ -0,0 +1,12 @@
+require 'test/unit'
+
+class Test_PathToClass < Test::Unit::TestCase
+ require '-test-/path_to_class/path_to_class'
+
+ def test_path_to_class
+ bug5691 = '[ruby-core:41410]'
+ assert_raise(ArgumentError, bug5691) {
+ Test_PathToClass.path_to_class("Test_PathToClass::Object")
+ }
+ end
+end
diff --git a/variable.c b/variable.c
index ae89e8eead..abdb39ad10 100644
--- a/variable.c
+++ b/variable.c
@@ -272,7 +272,7 @@ rb_path_to_class(VALUE pathname)
p += 2;
pbeg = p;
}
- if (!rb_const_defined(c, id)) {
+ if (!rb_const_defined_at(c, id)) {
undefined_class:
rb_raise(rb_eArgError, "undefined class/module %.*s", (int)(p-path), path);
}