Skip to content

Doesn't support 'false' value of boolean type #29

Description

@youlanhai

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions