LuaLS / LuaLS/lua-language-server
Infer pcall arguments from the first function parameter
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
Hi 👋
I was wondering if it would be possible for LuaLS to infer the types of the arguments passed to pcall based on the signature of its first function argument. This would significantly improve developer experience, especially when working with typed Lua (e.g., EmmyLua annotations) or when relying on auto-completion and type checking.
Example:
local function greet(name: string)
print("Hello, " .. name)
end
pcall(greet, "world")
^- here we should see `name: string`
In this case, it would be great if LuaLS could infer that greet expects a string, and therefore type-check or suggest "world" accordingly when passed to pcall.
Currently, the parameters after the first one are not checked or suggested with much context, making it less ergonomic when using pcall (or other similar functions) for safe calls.
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
Start by tracing how LuaLS handles the pcall call shown in the example and how it checks arguments against a function signature. Identify the relevant type-checking and completion paths, then verify that arguments after the first function parameter receive the expected context for typed Lua calls.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- developer-experience, devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100