LuaLS / LuaLS/lua-language-server

For loop with negative step: false positive

Open
#2,973 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
4.4k
Forks
442
PR merge metrics
No merged PRs in 30d

Description

### How are you using the lua-language-server?

NeoVim

### Which OS are you using?

Windows WSL

### What is the issue affecting?

Diagnostics/Syntax Checking

### Expected Behaviour

Warning shouldn't be displayed

### Actual Behaviour

Warning is displayed

### Reproduction steps

```lua
local r = 1
for x = -r, 1 do
print(x)
end
```

### Additional Notes

Tested on 3.13.2.
![image](https://github.com/user-attachments/assets/d10515a1-ded2-45d3-b1bb-dbbe94913046)

### Log File

I am using nvim + mason, and it does not save any logs even with command line arguments.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the provided Lua snippet in LuaLS 3.13.2 through the reported Neovim setup and confirm the diagnostic under Diagnostics/Syntax Checking. Trace how numeric for loops are analyzed, then verify that this valid loop no longer produces the warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, neovim
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.