lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Tue, Feb 15, 2011 at 9:31 AM, Jon Akhtar <> wrote:
> [IntelliJ IDE inspections can] find common flaws in code and either flag them,
> or flag them and offer to fix them. [...]
> a,b,c = 1,2
> [...] I am looking for more, so I thought I would ask the list for some suggestions.[...]
On Tue, Feb 15, 2011 at 10:02 AM, Jon Akhtar <> wrote:
> -- Function is last (cannot determine)
> a, b, c = 1, b()

A similar case is

  local function ff(xx,yy)
    if yy then return xx+yy, xx-yy else return xx end
  local aa, bb, cc = ff(5)

Here, you could flag an argument count mismatch on the `ff` call,
although this can be a false positive if arguments are optional, as is
the case here.  You may also infer that `cc` is `nil` (or actually
none) since all the return paths of `ff` return no more than two

A lot of things can also be flagged via data flow analysis
(propagating values+types):

  local xx = {}
  local function ff() return xx + xx end
  local yy = ff()

Here, `yy` can be inferred as never getting set to a value, due to
"attempt to perform arithmetic" error.

LuaInspect handles or at least knows about the above cases.