Skip to content

泛型for迭代器的类型推导漏掉了带__call的类 #3463

Description

@blanhhy

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

---@class Iter
---@operator call:number?
local iter

for i in iter do end -- 'i' should be 'number'

Actual Behaviour

---@class Iter
---@operator call:number?
local iter

for i in iter do end -- 'i' is 'unknown'

Reproduction steps

  1. copy the code above into IDE
  2. hover the mouse over the var i

Additional Notes

原因是luals在构造迭代器节点时,只对第一个表达式使用getReturn,而后者只能用来得到函数的返回类型。后续未处理__call的情况,导致除了函数之外的所有callable都被忽略。

Log File

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions