LuaLS / LuaLS/lua-language-server
Can not infer basic assignments in nested loop.
還沒有人認領這個 Issue。
- 主要語言
- Lua
- 星號
- 4.4k
- 分支
- 442
- PR 合併指標
- 30 天內沒有已合併 PR
描述
### Discussed in https://github.com/LuaLS/lua-language-server/discussions/2471
Originally posted by **Luke100000** January 8, 2024
Why can it not infer the type here? How would I rewrite this to be type conform, without spamming type annotations?
```lua
local y = 0
for i = 1, 2 do
y = y + 1 -- here, y is inferred as an integer correctly
for j = 1, 2 do
y = y + 1 -- can not infer type
end
-- sometimes a bit more complexity is required to trigger the issue, so lets add another loop
for j = 1, 2 do
y = y + 1 -- can not infer type
end
end
print(y)
```
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先重現 issue 中的巢狀迴圈範例,並閱讀 discussion 2471 以了解現有分析。追蹤 language server 如何透過迴圈中的指派推斷 y。當所示指派能保留推斷出的 integer 型別,而不需要重複的型別註記時,即視為完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- lua
- 領域
- devtools
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100