lua-pb
lua-pb copied to clipboard
Doesn't support 'false' value of boolean type
I'm sorry, i'm not good at English.
For example:
// protobuf
message MyProto
{
required bool boolField = 1;
}
-- lua codes
local p = MyProto()
p.boolField = false
print(p:HasField("boolField")) -- the result is: false
print(p:Serialize()) -- the result is: false, Missing require field
The false
value of boolean type was not supported.
The following is source code of lua-pb/message.lua
function methods:HasField(name)
local data = rawget(self, '.data') -- field data.
return not not data[name]
end
I think the code return not not data[name]
may be replaced with return data[name] ~= nil
. The same problem for Serialize
and some other methods.