diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-12-05 08:01:05 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-12-05 08:01:05 +0900 |
| commit | 00d1fd0e6fee6cef2565c4a3b2dd428b0d59f4bf (patch) | |
| tree | 85e11ad929cb0e14879c7e4944a2be52aa1142a2 /src/class.c | |
| parent | 3972df57fe70a29e6bf6db590dd22651640a1217 (diff) | |
| download | mruby-00d1fd0e6fee6cef2565c4a3b2dd428b0d59f4bf.tar.gz mruby-00d1fd0e6fee6cef2565c4a3b2dd428b0d59f4bf.zip | |
Fixed a bug with modules prepended many times.
Adjust insertion point in `fix_prepend_module()`.
Diffstat (limited to 'src/class.c')
| -rw-r--r-- | src/class.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/class.c b/src/class.c index a421325a3..7141fe099 100644 --- a/src/class.c +++ b/src/class.c @@ -1449,11 +1449,15 @@ fix_prepend_module(mrb_state *mrb, struct RBasic *obj, void *data) if (c->tt == MRB_TT_CLASS || c->tt == MRB_TT_MODULE) { struct RClass *p = c->super; + struct RClass *ins_pos = c; while (p) { if (c == m[0]) break; + if (p == m[0]->super->c) { + ins_pos = c; + } if (p->tt == MRB_TT_CLASS) break; if (p->c == m[0]) { - include_module_at(mrb, c, c, m[1], 0); + include_module_at(mrb, ins_pos, ins_pos, m[1], 0); break; } c = p; |
