On Tue, Sep 9, 2008 at 10:17 PM, Eric Gerlach <eric-ruby-talk / gerlach.ca> wrote:
> I'm trying to marshal some data using Ruby's YAML library, but the files
> that YAML.rb is creating aren't loading up properly.  I've brought in
> the libraries from the most recent 1.8.6 branch, but the problem isn't
> solved there.
>
> I've attached a stub script which demonstrates the problem.  If someone
> who has 1.8.7 can test it and let me know the results, that would be a
> huge help. (The script should print some stuff and *not* crash out with
> an exception).

I don't have 1.8.7 handy, but 1.8.6 and JRuby 1.1:

$ ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-linux]

$ ruby x.rb
/usr/lib/ruby/site_ruby/1.8:/usr/lib/ruby/site_ruby/1.8/i386-linux:/usr/lib/ruby
/site_ruby:/usr/lib/site_ruby/1.8:/usr/lib/site_ruby/1.8/i386-linux:/usr/lib/sit
e_ruby:/usr/lib/ruby/1.8:/usr/lib/ruby/1.8/i386-linux:.#<Test1:0xb7e558f0
 @f1="Test",
 @p=nil,
 @z=
  [#<Test1:0xb7e557b0
    @f1="Test2",
    @p=#<Test1:0xb7e558f0 ...>,
    @z=[#<Test1:0xb7e55774 @f1="Test3", @p=#<Test1:0xb7e557b0 ...>>]>]>
#<Test1:0xb7e53b40
 @f1="Test",
 @p=nil,
 @z=[#<Test1:0xb7e53780 @f1="Test2", @p=#<Test1:0xb7e53b40 ...>, @z=nil>]>
Test3
x.rb:31: undefined method `[]' for nil:NilClass (NoMethodError)

$ jruby -v
ruby 1.8.6 (2008-03-28 rev 6360) [i386-jruby1.1]

$ jruby x.rb
/usr2/java/jruby-1.1/lib/ruby/site_ruby/1.8:/usr2/java/jruby-1.1/lib/ruby/site_r
uby:/usr2/java/jruby-1.1/lib/ruby/1.8:/usr2/java/jruby-1.1/lib/ruby/1.8/java:lib
/ruby/1.8:.#<Test1:0xc
 @f1="Test",
 @p=nil,
 @z=
  [#<Test1:0x18
    @f1="Test2",
    @p=#<Test1:0xc ...>,
    @z=[#<Test1:0x24 @f1="Test3", @p=#<Test1:0x18 ...>>]>]>
#<Test1:0x2c
 @f1="Test",
 @p=nil,
 @z=
  [#<Test1:0x38
    @f1="Test2",
    @p=#<Test1:0x2c ...>,
    @z=[#<Test1:0x44 @f1="Test3", @p=#<Test1:0x38 ...>>]>]>
Test3
Test3