Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Nil access check does not run #2930

Open
opfromthestart opened this issue Nov 2, 2024 · 0 comments
Open

Nil access check does not run #2930

opfromthestart opened this issue Nov 2, 2024 · 0 comments

Comments

@opfromthestart
Copy link

How are you using the lua-language-server?

Other

Which OS are you using?

Linux

What is the issue affecting?

Diagnostics/Syntax Checking

Expected Behaviour

I have the minimal example

---@class A
---@field b fun(self: A): table?

---@return A[]
local function get_A()
  local l = {}
  for _ = 1, 10 do
    if math.random() > 0.5 then
      table.insert(l, { b = function(self) return { f = 4 } end })
    else
      table.insert(l, { b = function(self) print("hi" .. tostring(self)) end })
    end
  end
  return l
end

local as = get_A()
for i = 1, 10 do
  local a = as[i]
  if a:b().f > 3 then
    print("yo")
  end
end

The lsp should give me an error about a:b().f as a:b() could be nil.

Actual Behaviour

No warnings are shown.

Reproduction steps

  1. Copy the given code into an editor
  2. See that no errors are shown

Additional Notes

No response

Log File

No response

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

No branches or pull requests

1 participant