BUG: 当_ENV作为多重赋值的第一个变量时, 后续变量会错误的识别成局部变量.
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 76
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
这是非常罕见的场景, 并且建议避免编写这种代码.
```lua
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插件](https://github.com/LuaLS/lua-language-server)错误提示.

Contributor guide
No contributing guide indexed for this repository
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 reproducing the Lua snippet through parser.compile and inspect state.ast.locals and the ast.type values for each assignment target. Compare the result for _ENV, a, a.x, and a[1]; done means the assignment no longer creates incorrect local variables or marks every target as 'local'.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100