lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

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

Open markrakosi225087 opened this issue 1 year ago • 1 comments

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

markrakosi225087 avatar Feb 27 '24 12:02 markrakosi225087

Doesn't work in the for loop either.

clay-golem avatar Mar 25 '24 10:03 clay-golem