Hi,

At Tue, 25 Jan 2005 15:46:37 +0900,
Yukihiro Matsumoto wrote in [ruby-core:04318]:
> It's reported in [ruby-list:40570].
> 
> # ruby -r yaml -e 'YAML.load({nil=>1}.to_yaml)'
> /usr/lib/ruby/1.8/yaml.rb:119:in `load': parse error on line 1, col 1: `: 1' (ArgumentError)
>         from /usr/lib/ruby/1.8/yaml.rb:119:in `load'
>         from -e:1
> 
> Is this a bug?

I believe so.

What about this patch?


Index: lib/yaml/baseemitter.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/yaml/baseemitter.rb,v retrieving revision 1.6 diff -U2 -p -r1.6 baseemitter.rb --- lib/yaml/baseemitter.rb 18 Aug 2004 20:42:09 -0000 1.6 +++ lib/yaml/baseemitter.rb 10 Aug 2005 07:49:05 -0000 @@ -173,5 +173,5 @@ module YAML self << "? " end - v[0].to_yaml( :Emitter => self ) + v[0].to_yaml( :Emitter => self, :ExplicitValue => true ) if v[0].is_complex_yaml? self << "\n" Index: lib/yaml/rubytypes.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/yaml/rubytypes.rb,v retrieving revision 1.28 diff -U2 -p -r1.28 rubytypes.rb --- lib/yaml/rubytypes.rb 7 Jun 2005 16:33:00 -0000 1.28 +++ lib/yaml/rubytypes.rb 10 Aug 2005 07:48:01 -0000 @@ -620,5 +620,5 @@ class NilClass def to_yaml( opts = {} ) opts[:KeepValue] = true - "".to_yaml( opts ) + (opts[:ExplicitValue] ? "null" : "").to_yaml( opts ) end end
-- Nobu Nakada