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

Reduce inconsistency with the table length operator in some cases #62

Merged
merged 5 commits into from
Dec 14, 2022

Conversation

Shiranuit
Copy link
Contributor

@Shiranuit Shiranuit commented Dec 13, 2022

What does this PR do ?

Fixes the issue #51

This PR tries to reduce inconsistency with the table length operator and be closer to the PUC Lua implementation.

Sorry I didn't add new test cases somehow I wasn't able to make them work on my side.

Actual version

print(#{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,nil,17,18,[33]={}})  -- 33
print(#{1,2,3,nil,5,nil,nil,8,9}) -- 5
print(#{1,2,3,nil,5,nil,7,8}) -- 3
print(#{1,2,3,nil,5,nil,7,8,9}) -- 9
print(#{1,nil,[2]=2,3}) -- 1

New Version

print(#{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,nil,17,18,[33]={}})  -- 18
print(#{1,2,3,nil,5,nil,nil,8,9}) -- 9
print(#{1,2,3,nil,5,nil,7,8}) -- 8
print(#{1,2,3,nil,5,nil,7,8,9}) -- 9
print(#{1,nil,[2]=2,3}) -- 3

PUC Lua Reference

print(#{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,nil,17,18,[33]={}})  -- 18
print(#{1,2,3,nil,5,nil,nil,8,9}) -- 9
print(#{1,2,3,nil,5,nil,7,8}) -- 8
print(#{1,2,3,nil,5,nil,7,8,9}) -- 9
print(#{1,nil,[2]=2,3}) -- 3

@SquidDev
Copy link
Member

Amazing, thank you! Will add a couple of tests this evening!

@SquidDev SquidDev linked an issue Dec 13, 2022 that may be closed by this pull request
@SquidDev SquidDev merged commit 4bd0b19 into cc-tweaked:master Dec 14, 2022
@SquidDev
Copy link
Member

Thank you so much!

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

Successfully merging this pull request may close these issues.

Awkward results from the length operator with multiple nil entries
2 participants