Skip to content
This repository has been archived by the owner on Mar 24, 2018. It is now read-only.

Message.merge_from fails if target has an unset field of a custom type #16

Open
aogail opened this issue Jan 23, 2014 · 0 comments
Open

Comments

@aogail
Copy link

aogail commented Jan 23, 2014

I am using ruby_protobuf version 0.4.11 and ruby 2.0.0p247.

Given a proto file:

message Foo {
}

message Bar {
    optional Foo f = 1;
}

Foo.merge_from() will fail if the target's f field is unset:

$ cat foo.rb
require './foo.pb'

b1 = Bar.new
b2 = Bar.new
b2.f = Foo.new
b1.merge_from(b2)

$ ruby foo.rb
/localhome/aogail/.rvm/gems/ruby-2.0.0-p247/gems/ruby_protobuf-0.4.11/lib/protobuf/message/field.rb:622:in `merge_value': undefined method `merge_from' for nil:NilClass (NoMethodError)
    from /localhome/aogail/.rvm/gems/ruby-2.0.0-p247/gems/ruby_protobuf-0.4.11/lib/protobuf/message/field.rb:104:in `merge'
    from /localhome/aogail/.rvm/gems/ruby-2.0.0-p247/gems/ruby_protobuf-0.4.11/lib/protobuf/message/message.rb:256:in `block in merge_from'
    from /localhome/aogail/.rvm/gems/ruby-2.0.0-p247/gems/ruby_protobuf-0.4.11/lib/protobuf/message/message.rb:256:in `each'
    from /localhome/aogail/.rvm/gems/ruby-2.0.0-p247/gems/ruby_protobuf-0.4.11/lib/protobuf/message/message.rb:256:in `merge_from'
    from foo.rb:6:in `<main>'
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant