Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

narcisobenigno opened this issue Nov 4, 2013 · 1 comment

Comments

@narcisobenigno
Copy link

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> 
@rinaldifonseca
Copy link

Boa NJ! @narcisobenigno

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants