summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
Diffstat (limited to 'class.c')
-rw-r--r--class.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/class.c b/class.c
index f57f53b11b..b35e1f82e6 100644
--- a/class.c
+++ b/class.c
@@ -349,11 +349,13 @@ rb_include_module(klass, module)
OBJ_INFECT(klass, 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(c)->super = include_class_new(module, RCLASS(c)->super);