I use luacheck (in the Atom editor), but open to other static analysis tools.
Is there a way to verify that I am using an uninitialized table field? I read the docs ( http://luacheck.readthedocs.io/en/stable/index.html ), but maybe I missed how to do this?
In all three cases, in the code below, I try to find that I (erroneously) used the 'y1' field. None of them do. (It was detected at runtime, but I'm trying to catch it before runtime).
local a = {}
a.x = 10
a.y = 20
print(a.x + a.y1) -- no warning about uninitialized field y1 !?
-- luacheck: globals b
b = {}
b.x = 10
b.y = 20
print(b.x + b.y1) -- no warning about uninitialized field y1 !?
-- No inline option for luacheck re: 'c', so plenty of complaints
-- about "non-standard global variable 'c'."
c = {} -- warning about setting
c.x = 10 -- warning about mutating
c.y = 20 -- " " "
print(c.x + c.y1) -- more warnings (but NOT about field y1)
The point is: as projects grow (increase in files and increase in the number and size of modules), it would be nice to prevent skipping such errors.
Thank.