Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
markrakosi225087 opened this issue Feb 27, 2024 · 1 comment
Open

Comments

@markrakosi225087
Copy link

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

@clay-golem
Copy link

Doesn't work in the for loop either.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants