local var
if cond then
var = value
else
func = function() return var end
end
value assigned to var should be reported as unused (and access of var in func function should be reported as accessing an uninitialized variable), but it's not.
Currently in analyze.lua it's assumed that an access in a closure can resolve to an assignment if the closure and the value can be live at the same CFG node. Instead, it should check that either the value reaches the closure or the closure reaches the value. Can be solved by tweaking the way values and closures are propagated in analyze.lua, no reason to switch to proper dataflow analysis.
E.g. when checking
value assigned to
var
should be reported as unused (and access ofvar
infunc
function should be reported as accessing an uninitialized variable), but it's not.Currently in
analyze.lua
it's assumed that an access in a closure can resolve to an assignment if the closure and the value can be live at the same CFG node. Instead, it should check that either the value reaches the closure or the closure reaches the value. Can be solved by tweaking the way values and closures are propagated inanalyze.lua
, no reason to switch to proper dataflow analysis.