ruby-protobuf / protobuf

A pure ruby implementation of Google's Protocol Buffers
https://github.com/ruby-protobuf
MIT License
463 stars 101 forks source link

Calling .to_s on a frozen proto will raise #400

Open malmckay opened 5 years ago

malmckay commented 5 years ago

Failing spec here → https://github.com/malmckay/protobuf/pull/1

https://github.com/ruby-protobuf/protobuf/commit/71b2fc09951d042d8d24470de9e3353b94144f22#diff-ef5972b95ab815a1753b6e1677178dac introduced an instance variable. For a frozen proto, setting that instance variable during encoding will raise.

Example stack trace:

     FrozenError:
       can't modify frozen Protobuf_unittest::TestAllTypes
     # ./lib/protobuf/message/fields.rb:30:in `_protobuf_message_unset_required_field_tags'
     # ./lib/protobuf/message.rb:73:in `each_field_for_serialization'
     # ./lib/protobuf/encoder.rb:4:in `encode'
     # ./lib/protobuf/message/serialization.rb:60:in `encode_to'
     # ./lib/protobuf/message/serialization.rb:53:in `encode'