LuaLS / LuaLS/lua-language-server

setfenv

Open
#2,503 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?

Linux

### What is the issue affecting?

Diagnostics/Syntax Checking

### Expected Behaviour

no error

### Actual Behaviour

```
Cannot assign `integer` to parameter `fun(...any):...integer|unknown`.
- `integer` cannot match `fun(...any):...integer|unknown`
- Type `integer` cannot match `fun(...any):...integer|unknown`
- Type `number` cannot match `fun(...any):...integer|unknown`Lua Diagnostics.(param-type-mismatch)
```

### Reproduction steps

Lua version 5.1
setfenv(, )

### Additional Notes

maybe change definition from
`---
---Sets the environment to be used by the given function.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-setfenv)
---
---@param f async fun(...):...|integer
---@param table table
---@return function
function setfenv(f, table) end`

to
`---
---Sets the environment to be used by the given function.
---
---[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-setfenv)
---
---@param f integer|async fun(...):...
---@param table table
---@return function
function setfenv(f, table) end`

### 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 locating the setfenv definition shown in the issue and compare its first parameter annotation with Lua 5.1's accepted argument forms. Reproduce the example in the Lua language server and verify that setfenv(, ) no longer reports a parameter-type mismatch.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
devtools
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.