lua-protobuf
lua-protobuf copied to clipboard
nested message with default values regression
With the latest lua-protobuf master, the assertion on the last line of this program is hit:
pb = require 'pb'
protoc = require 'protoc'
assert(protoc:load[[
syntax = "proto3";
package repro;
message Inner {
string value = 1;
}
message Outer {
Inner inner = 1;
}
]])
outer = {inner={value=""}}
assert(outer)
assert(outer.inner)
m = assert(pb.decode('repro.Outer', assert(pb.encode('repro.Outer', outer))))
assert(m.inner, 'inner')
As follows:
lua5.4: repro.lua:25: inner
stack traceback:
[C]: in function 'assert'
repro.lua:25: in main chunk
[C]: in ?
This does not happen with older versions of lua-protobuf. After a git bisect, I've narrowed the change in behavior down to commit 7de8652a02a19a421698e2cbf8c2460108552bf1. From the commit description, this change does not appear to be intentional.
This commit fix a encode bug, if you need default message, use option "decode_default_message"