From 0f47249963662894699cbd87a786ff984c79dad7 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 17 Mar 2026 16:12:07 +0900 Subject: [PATCH] class.c: clear const cache on include/prepend mrb_include_module() and mrb_prepend_module() did not invalidate the constant cache. stale cache entries caused incorrect constant resolution after include changed the ancestor chain. Co-authored-by: Claude --- src/class.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/class.c b/src/class.c index 019aa058e..54061c29a 100644 --- a/src/class.c +++ b/src/class.c @@ -1970,6 +1970,7 @@ mrb_include_module(mrb_state *mrb, struct RClass *c, struct RClass *m) if (include_module_at(mrb, c, find_origin(c), m, 1) < 0) { mrb_raise(mrb, E_ARGUMENT_ERROR, "cyclic include detected"); } + mrb_const_cache_clear(mrb); if (c->tt == MRB_TT_MODULE && (c->flags & MRB_FL_CLASS_IS_INHERITED)) { struct RClass *data[2]; data[0] = c; @@ -2039,6 +2040,7 @@ mrb_prepend_module(mrb_state *mrb, struct RClass *c, struct RClass *m) if (include_module_at(mrb, c, c, m, 0) < 0) { mrb_raise(mrb, E_ARGUMENT_ERROR, "cyclic prepend detected"); } + mrb_const_cache_clear(mrb); if (c->tt == MRB_TT_MODULE && (c->flags & (MRB_FL_CLASS_IS_INHERITED|MRB_FL_CLASS_IS_PREPENDED))) { struct RClass *data[2];