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

types.is_empty fails for tables with boolean keys #267

Closed
ethernidee opened this issue Jan 20, 2018 · 1 comment
Closed

types.is_empty fails for tables with boolean keys #267

ethernidee opened this issue Jan 20, 2018 · 1 comment

Comments

@ethernidee
Copy link

if o == nil or (type(o) == "table" and not next(o))

not next(o) should be probably replaced with next(o) == nil, because it's valid to store FALSE as table key. If FALSE is returned as first key, the check will treat table as empty. The order of key traversals is undefined, thus types.is_empty can produce random bugs.

Proof:
types.is_empty({ [false] = 777 }) -- true

@mpeterv
Copy link
Contributor

mpeterv commented Sep 21, 2018

Fixed.

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

No branches or pull requests

2 participants