Skip to content

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

@bananu7

Description

@bananu7

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.

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