From: Eric Hodel Date: 2008-04-09T06:19:59+09:00 Subject: Re: Marshal and singleton.rb - bug? On Apr 8, 2008, at 10:31 AM, Chris Shea wrote: > I was looking over the documentation for singleton.rb (because I want > to help it), and while I was double-checking assumptions I had, I > noticed that Marshal.load of a serialized singleton instance didn't > return the singleton instance, but a new one. I assume that the > expected behavior is that Marshal.load would be to return the sole > instance. > > I wrote a simple test case here: http://pastie.textmate.org/177309 There's assert_same which does the #equal? comparison. > My installation of Ruby (ruby 1.8.6 (2007-03-13 patchlevel 0) > [i686-darwin9.1.0]) fails the last two, as does trunk (r15929). > > Are my assumptions correct? In order for this to work as you expect, Marshal would need to replace the existing instance, which is out of it's scope. It might be possible to "fix" by overwriting allocate, but that seems dangerous.