LuaLS / LuaLS/lua-language-server
`repeat…until val ~= nil` should satisfy the need for nil checks
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
I have some code where I have to wait for a forked process to create a file and I can't get feedback over its return status or stdout, so I use a polling pattern similar to this:
```lua
local val = nil
-- kick off the external process
fork_process(...)
repeat
val = check_for_val(...)
until val ~= nil
val:foo()
```
In this current form, I get a diagnostic that says I need to perform a nil check on `val` before calling `foo`, but the loop condition here should be considered the nil check.
This already works for `while val == nil do...end` so it would be nice to see it for `repeat...until val~= nil` as well.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no source file or test; start by locating the flow-analysis logic that handles nil checks for while loops and repeat…until conditions. Reproduce the polling example and compare its diagnostic with the existing while val == nil behavior; done when val:foo() no longer requires an extra nil check after repeat…until val ~= nil.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100