Skip to content

Wrongly detects unreachable code #2282

Open
@lal12

Description

@lal12

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Linux

What is the issue affecting?

Diagnostics/Syntax Checking, Hover

Expected Behaviour

Given the following code

local arr = {}

for k,v in pairs(arr) do
	if k == 1 then
		print("k == 1")
		error("hi", k, v)
	else
		error("hi", k, v)
	end
end

print("hello world")

print in the last line should not be marked as unreachable, since arr is empty and error is never called.

Actual Behaviour

print in the last line is marked as unreachable.

grafik

Reproduction steps

  1. Open New Tab in VSCode
  2. Paste code example from above
  3. if not set automatically, change language to lua
  4. see last line being greyed out

Additional Notes

No response

Log File

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions