LuaLS / LuaLS/lua-language-server

Advanced missing nil check

Open
#1,214 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

This is probably really hard to "fix".
```lua
---@type table|nil
local blueprint = { x = 1 }
local hasBlueprint = true

if blueprint == nil then
hasBlueprint = false
end

if hasBlueprint then
error("no blueprint found")
end

local s = blueprint.x
```
![grafik](https://user-images.githubusercontent.com/56718716/173940726-c38cdcfb-acf4-41a1-aad5-00e0d6931997.png)

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

Start by reproducing the provided Lua example and inspect the language server's nil-check and control-flow analysis. Confirm the expected diagnostic for the access to blueprint.x, then trace the relevant analyzer entry point and add or update focused coverage so the shown case is handled consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
devtools
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.