From c9cf552a91f7248b73e2e7cab5b423861176a95c Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 28 Jan 2002 08:42:40 +0000 Subject: * 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 --- class.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'class.c') diff --git a/class.c b/class.c index f906390246..b4d8c935ae 100644 --- a/class.c +++ b/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; -- cgit v1.2.3