Skip to content

Adds support for continuing to track tables across function calls#67

Draft
arichard4 wants to merge 3 commits into
lunarmodules:masterfrom
arichard4:fields_functions
Draft

Adds support for continuing to track tables across function calls#67
arichard4 wants to merge 3 commits into
lunarmodules:masterfrom
arichard4:fields_functions

Conversation

@arichard4

Copy link
Copy Markdown

On top of #65

The basic idea:
When a function is called, there's a few things relevant to table fields that could happen:
(1) The function could be called as a method, i.e. invoked on a table, i.e. table:function(); we need to stop tracking it
(2) The table as a whole could be passed to the function; we need to stop tracking it
(3) Externally accessible fields could have arbitrary reads, writes, or aliases; we need to stop tracking them
(4) A specific field from the table could be passed; this is an access to that field

Here's some sample code to illustrate why cases 1-3 need to outright stop tracking the table in question, rather than marking all keys are potentially read/written and marking the table as being externally referenceable:

local t
local function func1(var)
   t = var
end
local x = {}
func1(x)
x[1] = 1
print(t[1])

local z = {}
local a
function z:func() a = self end
z:func()
z[1] = 1
print(a[1])

local y
local function func2() return y end
function func3()
   y = {}
   local t = func2()
   y[1] = 1
   print(t[1])
end

Note that this is one of two pieces of function-call related functionality; the other is handling for builtin functions: type, pairs, ipairs, next, table.insert, table.remove, table.sort, table.concat.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant