Merge (<<) with !ruby/object problem #169

Closed
narcisobenigno opened this Issue Nov 4, 2013 · 1 comment

Projects

None yet

2 participants

@narcisobenigno

This works with syck, but doesn't work with psych:

irb(main):013:0> s = <<EOF
irb(main):014:0" foo: &foo
irb(main):015:0"   bar: 10
irb(main):016:0" product:
irb(main):017:0"   !ruby/object:Product
irb(main):018:0"   <<: *foo
irb(main):019:0" EOF
=> "foo: &foo\n  bar: 10\nproduct:\n  !ruby/object:Product\n  <<: *foo\n"
irb(main):020:0> Product = Class.new
=> Product
irb(main):021:0> YAML.load(s)
NameError: `@<<' is not allowed as an instance variable name
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:321:in `instance_variable_set'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:321:in `block in init_with'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:321:in `each'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:321:in `init_with'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:306:in `revive'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:178:in `visit_Psych_Nodes_Mapping'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/visitor.rb:15:in `visit'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/visitor.rb:5:in `accept'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:20:in `accept'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:268:in `block in revive_hash'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:266:in `each'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:266:in `each_slice'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:266:in `revive_hash'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:141:in `visit_Psych_Nodes_Mapping'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/visitor.rb:15:in `visit'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/visitor.rb:5:in `accept'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:20:in `accept'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:240:in `visit_Psych_Nodes_Document'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/visitor.rb:15:in `visit'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/visitor.rb:5:in `accept'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:20:in `accept'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych/nodes/node.rb:35:in `to_ruby'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/2.0.0/psych.rb:130:in `load'
    from (irb):21
    from /usr/local/bin/irb:12:in `<main>'irb(main):022:0> 
@tenderlove tenderlove added a commit that closed this issue Nov 5, 2013
@tenderlove tenderlove * ext/psych/lib/psych/visitors/to_ruby.rb: process merge keys before
  reviving objects. Fixes GH psych #168
* test/psych/test_merge_keys.rb: test for change
  #168

Fixes #169
1003a03
@tenderlove tenderlove closed this in 1003a03 Nov 5, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment