Bug #8041

Marshal incompatibility with prepend

Added by Marc-Andre Lafortune about 1 year ago. Updated about 1 year ago.

[ruby-core:53202]
Status:Closed
Priority:Low
Assignee:-
Category:core
Target version:2.1.0
ruby -v:r39629 Backport:

Description

=begin
Marshal doesn't work for objects with prepended modules:

o = Object.new
o.singleton_class.send :include, Enumerable
Marshal.load(Marshal.dump(o)) # => ok

o = Object.new
o.singleton_class.send :prepend, Enumerable
Marshal.load(Marshal.dump(o)) # => ArgumentError: Object does not refer to module

=end

Associated revisions

Revision 39642
Added by Nobuyoshi Nakada about 1 year ago

marshal.c: prepended objects

  • marshal.c (r_object0): load prepended objects. treat the class of extended object in the included modules as prepended singleton class. [Bug #8041]

History

#1 Updated by Nobuyoshi Nakada about 1 year ago

  • Description updated (diff)

=begin
To be honest, I haven't considered about marshaling prepended objects at all.
How could we represent it?

(1) add new type, (({TYPE_PREEXTEND})) for example.
(2) allow the current dumped format and treat the class in extending modules as the mark of prepend.

The former may need marshal version to bump up, I don't want it.
=end

#2 Updated by Nobuyoshi Nakada about 1 year ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r39642.
Marc-Andre, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


marshal.c: prepended objects

  • marshal.c (r_object0): load prepended objects. treat the class of extended object in the included modules as prepended singleton class. [Bug #8041]

Also available in: Atom PDF