Skip to content

Comparing against type overrides it #1841

@firas-assaad

Description

@firas-assaad

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, Hover

Expected Behaviour

Trying the following minimal example:

---@param v integer
---@return boolean
local function is_string(v)
    return type(v) == 'string'
end

print(is_string(3))

The type of the parameter v should be integer, and I shouldn't get any warnings about passing an integer value to is_string.

Actual Behaviour

I get a type mismatch at is_string(3):

image

Hovering over v inside the is_string function also shows its type as string instead of integer.

Reproduction steps

  1. Try the code above in vscode with extension version 3.6.7

Additional Notes

No response

Log File

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions