Skip to content

discard-returns warning is not triggered in while/repeat loops #2549

@markrakosi225087

Description

@markrakosi225087

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Annotations

Expected Behaviour

@NODISCARD annotated functions should always trigger the discard-returns warning in any context.

Actual Behaviour

discard-returns does not trigger in while and repeat loops.

Reproduction steps

---@nodiscard
local function bar()
 --@nodiscard annotated function
end
	
while true do
   bar() --< this DOES NOT trigger no-discard
   break
end

repeat 
   bar() --< this DOES NOT trigger no-discard
   break
until true

bar() -- < this DOES trigger no-discard

for index, value in ipairs({}) do
	bar()  -- < this DOES trigger no-discard
end

Additional Notes

No response

Log File

No response

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