aboutsummaryrefslogtreecommitdiffstats
path: root/vm.c
diff options
context:
space:
mode:
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/vm.c b/vm.c
index e62c9a4b7b..eb49722fcd 100644
--- a/vm.c
+++ b/vm.c
@@ -1844,6 +1844,11 @@ vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval,
rb_iseq_t *miseq;
GetISeqPtr(iseqval, miseq);
+ if (miseq->klass) {
+ iseqval = rb_iseq_clone(iseqval, 0);
+ GetISeqPtr(iseqval, miseq);
+ }
+
if (NIL_P(klass)) {
rb_raise(rb_eTypeError, "no class/module to add method");
}