Issue #8043 has been updated by marcandre (Marc-Andre Lafortune).


My understanding is that objects whose singleton classes have included / prepended classes should be dumpable & loadable, but if the singleton class itself has proper instance methods it can't be dumped.

In the example I gave, the first TypeError is ok, since o's singleton class has a :foo method.

Prepending a module should not make it suddenly dumpable.

The check for this is in `w_extended` is incorrect. If I'm not mistaken, it assumes that the singleton class is first in the ancestry chain, which is no longer necessarily the case.
----------------------------------------
Bug #8043: Marshal will dump some object with singleton methods
https://bugs.ruby-lang.org/issues/8043#change-37400

Author: marcandre (Marc-Andre Lafortune)
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: current: 2.1.0
ruby -v: r39608


=begin
The check for "dumpability" is incorrect:

    o = Object.new
    def o.foo; end
    Marshal.dump(o) # => TypeError: singleton can't be dumped
    o.singleton_class.send :prepend, Enumerable
    Marshal.dump(o) # => "\x04\be:\x0FEnumerablee:\vObjecto;\x06\0", should fail
=end


-- 
http://bugs.ruby-lang.org/