1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2011-11-30 14:44:06 +00:00
parent ed73a902b8
commit f6f4534382
5 changed files with 34 additions and 1 deletions

View file

@ -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> 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. * transcode.c: Simplified rb_econv_binmode, avoided a warning on cygwin.

View file

@ -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")

View file

@ -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);
}

View file

@ -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

View file

@ -272,7 +272,7 @@ rb_path_to_class(VALUE pathname)
p += 2; p += 2;
pbeg = p; pbeg = p;
} }
if (!rb_const_defined(c, id)) { if (!rb_const_defined_at(c, id)) {
undefined_class: undefined_class:
rb_raise(rb_eArgError, "undefined class/module %.*s", (int)(p-path), path); rb_raise(rb_eArgError, "undefined class/module %.*s", (int)(p-path), path);
} }