Issue #9813 has been updated by Usaku NAKAMURA. Backport changed from 2.0.0: REQUIRED, 2.1: DONE to 2.0.0: DONE, 2.1: DONE ---------------------------------------- Bug #9813: Module#initialize_copy does not clean the tables https://bugs.ruby-lang.org/issues/9813#change-47405 * Author: Nobuyoshi Nakada * Status: Closed * Priority: Normal * Assignee: * Category: core * Target version: * ruby -v: r45873 * Backport: 2.0.0: DONE, 2.1: DONE ---------------------------------------- `Module#initialize_copy`で定数やインスタンス変数を持たない`Module`をコピーしても、元の定数やインスタンス変数が残っています。 ~~~ruby m = Module.new do def x end const_set(:X, 1) @x = 2 end p m.instance_methods, m.instance_variables, m.constants #=> [:x] #=> [:@x] #=> [:X] m.module_eval do initialize_copy(Module.new) end p m.instance_methods, m.instance_variables, m.constants #=> [] #=> [:@x] #=> [:X] ~~~ 1.8で`initialize_copy`が導入された当初からあるバグのようです。 -- https://bugs.ruby-lang.org/