Skip to content

Cannot type for-loop variable #2487

@saecki

Description

@saecki

How are you using the lua-language-server?

NeoVim

Which OS are you using?

Linux

What is the issue affecting?

Type Checking, Diagnostics/Syntax Checking

Expected Behaviour

The variables s and r are typed according to the @type annotation.

Actual Behaviour

In the following code snippet I cannot type the for loop variables s and r using the @type annotation:

    ---@type integer, string
    for s, r in str:gmatch("[,]?%s*()([^,]+)%s*[,]?") do
        ...
    end

Instead I get a Can not infer type. error for r and s is shown as of type string

Reproduction steps

Additional Notes

I think #1367 enabled this, but only for primitive for loops.

Log File

No response

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