Unsealed table refinement leaking from scope
Refining an unsealed table inside a scope will allow for that refinement to leak:
local t = {}
local function f()
t.a = 1
end
print(t.a) -- f's refinement leaks, despite not calling f
This also happens with conditionals like if false then t.a = 1 end.
Extending tables in this way is meant to be an affordance to infer types of tables that are initialized piecemeal. Code like what you describe isn't really what it was meant for.
The assignment to t.a should probably not be allowed. Would that break existing code?
I personally don't have any code that depends on this behavior. Although I do think it should be allowed in nonstrict because there are some crazy people who do stuff like this:
local function f(a)
local t = {}
if a then
t.a = a
end
return t
end
Otherwise, this definitely should not be allowed in strict.