LuaLS / LuaLS/lua-language-server

Annotation type any not working properly

Open
#2,637 0 comments 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?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Type Checking

Expected Behaviour

Variant 1:
Type 'any' allows any type except 'nil'. Type nil it's nil, not any.
@param cc any|nil should allow to use nil type

Variant 2:
When checking a type, you need to always have an argument, no matter what type. The argument must be specified in the method call. Сalling with an empty argument is not allowed

Variant 3: a special flag in param annotation that indicates an argument must be specified here

Actual Behaviour
---@param cc any
local function Test(cc)
	print(cc)
end

Test() -- no error

Type any allow nil type.

For example:
LUA + luabind C++.
C++ required argument on all bindings. Test(nil) and Test() have different behaviour for luabind.

Reproduction steps
  1. Go to '...'
  2. Click '...'
  3. See error '...'
Additional Notes

No response

Log File

No response

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 reported annotation example in the Visual Studio Code extension: compare Test() with Test(nil) for @param cc any and @param cc any|nil. The issue presents several possible semantics but names no source file or test; first determine which rule is intended, then verify that the completed behavior distinguishes omitted arguments from explicit nil.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.