Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]pairs and ipairs中---@type出错 #1166

Closed
HiKit opened this issue May 24, 2022 · 1 comment
Closed

[Bug]pairs and ipairs中---@type出错 #1166

HiKit opened this issue May 24, 2022 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@HiKit
Copy link

HiKit commented May 24, 2022

版本 v3.2.3

CfgVO.lua

---@class CfgVO
---@field id number
---@field p1 string
---@field p2 string

main.lua

---@type CfgVO
local cfg = {};
print(cfg.id, cfg.p1, cfg.p2)

for i=1, 10 do
    ---@type CfgVO
    local cfg = {};
    print(cfg.id, cfg.p1, cfg.p2)
end


local tmp = {}
for k,v in pairs(tmp) do
    ---@type CfgVO
    local cfg = {};
    print(cfg.id, cfg.p1, cfg.p2)
end

如下图,for循环中cfg识别正常,但是for pairs中识别错误
image

image

@sumneko sumneko added the duplicate This issue or pull request already exists label May 25, 2022
@sumneko
Copy link
Collaborator

sumneko commented May 25, 2022

duplicate with #1150

@sumneko sumneko closed this as completed May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants