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

Nil shouldn't be a valid table value (and should clear on set), but... #77

Open
bananu7 opened this issue Aug 11, 2021 · 0 comments
Open

Comments

@bananu7
Copy link
Owner

bananu7 commented Aug 11, 2021

but it's a huge issue with the way local declarations are currently handled. Consider this test:

x = 1
function f()
  local x = 2
end
f()
return x

Because of how locals are implemented, they just reside in a table. The local x = 2 assignment desugars to local x; x = 2, but with the new nil assignment rules (setting to nil deletes the key), the first statement doesn't do anything.

This is the code I tested with (Util.hs):

setTableField tRef (k, Nil) = LuaMT $ tables . at tRef . traversed . mapData %= delete k

I'm not sure how important this is, frankly. I mean, of course leftover nils are going to be a problem at some point, but it's not like you can clear a local def anyway, and it's not observable in tables unless native api is used. Fixing it would require changing the way local closures are stored, or at the very least give them a bypass that allows setting them to nil for the purpose of tracking keys.

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