summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-01-28 08:42:40 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-01-28 08:42:40 +0000
commitc9cf552a91f7248b73e2e7cab5b423861176a95c (patch)
tree8dc3e9ac704d3f5789f5547d0de557712d390b36 /class.c
parent5f12cd3e24538d79581e6572badcca1a6d3ae95e (diff)
* 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
Diffstat (limited to 'class.c')
-rw-r--r--class.c13
1 files changed, 7 insertions, 6 deletions
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;