lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

BUG: 当_ENV作为多重赋值的第一个变量时, 后续变量会错误的识别成局部变量.

Open 1514599514 opened this issue 1 year ago • 1 comments

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

这是非常罕见的场景, 并且建议避免编写这种代码.

local env = _ENV
_ENV, a = {}, 1
env.print(env.a, a) -- 1 nil

使用parser.compile函数解析得到的state.ast.locals会多出错误的局部变量_ENV和a. 整个多重赋值语句都会识别成local变量定义, 不管是a, a.x, a[1]形式, 生成的ast.type字段都会被错误的标识成'local'.

同时也会导致vscode插件错误提示. image

Actual Behaviour

错误的将多重赋值语句, 识别成了局部变量定义语句.

Reproduction steps

.

Additional Notes

No response

Log File

No response

1514599514 avatar Apr 17 '24 15:04 1514599514

May be a separate issue but definition files that have _ENV in them will break all further annotations in the same file when loaded by the extension as well.

vallode avatar Apr 19 '24 11:04 vallode