Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
youlanhai opened this issue Jan 3, 2017 · 0 comments
Open

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

youlanhai opened this issue Jan 3, 2017 · 0 comments

Comments

@youlanhai
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant