Skip to content

invalid "Impossible if statement: this condition is always falsy [unnecessary-if]"Β #888

@MagicDuck

Description

@MagicDuck

Hello! πŸ‘‹
Thank you for your hard work on this amazing language server!

I have run into a pattern where unnecessary-if / unused rules do not seem to function correctly. Observe below (this is a simplified example, but the pattern occurs in more complex code):
Image

The if-statement should not be "impossible" and bar should not be "unused".

This is the code to easily reproduce:

local mytable = {}
local bar = nil
function foo()
  if bar then
    table.insert(mytable, 'hello')
  end
end

bar = true
foo()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions