mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (is_defined): defined?(Foo::Baz) should check constants
only, no methods. * eval.c (is_defined): should not dump core on defined?(a::b) where a is not a class nor a module. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@2020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5f12cd3e24
commit
c9cf552a91
7 changed files with 35 additions and 16 deletions
13
class.c
13
class.c
|
@ -304,7 +304,7 @@ void
|
|||
rb_include_module(klass, module)
|
||||
VALUE klass, module;
|
||||
{
|
||||
VALUE p;
|
||||
VALUE p, c;
|
||||
int changed = 0;
|
||||
|
||||
rb_frozen_class_p(klass);
|
||||
|
@ -323,18 +323,19 @@ rb_include_module(klass, module)
|
|||
Check_Type(module, T_MODULE);
|
||||
}
|
||||
|
||||
c = klass;
|
||||
while (module) {
|
||||
if (RCLASS(klass)->m_tbl == RCLASS(module)->m_tbl)
|
||||
rb_raise(rb_eArgError, "cyclic include detected");
|
||||
/* ignore if the module included already in superclasses */
|
||||
for (p = RCLASS(klass)->super; p; p = RCLASS(p)->super) {
|
||||
if (BUILTIN_TYPE(p) == T_ICLASS &&
|
||||
RCLASS(p)->m_tbl == RCLASS(module)->m_tbl) {
|
||||
goto skip;
|
||||
if (BUILTIN_TYPE(p) == T_ICLASS) {
|
||||
if (RCLASS(p)->m_tbl == RCLASS(module)->m_tbl)
|
||||
goto skip;
|
||||
}
|
||||
}
|
||||
RCLASS(klass)->super = include_class_new(module, RCLASS(klass)->super);
|
||||
klass = RCLASS(klass)->super;
|
||||
RCLASS(c)->super = include_class_new(module, RCLASS(c)->super);
|
||||
c = RCLASS(c)->super;
|
||||
changed = 1;
|
||||
skip:
|
||||
module = RCLASS(module)->super;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue