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

Unexpected type mismatch with alias types. #85

Closed
vsaulue opened this issue Jun 22, 2021 · 0 comments
Closed

Unexpected type mismatch with alias types. #85

vsaulue opened this issue Jun 22, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@vsaulue
Copy link

vsaulue commented Jun 22, 2021

Environment

name version
IDEA version 2021.1.1 Community Edition (build #IC-211.7142.45)
Luanalysis version 1.2.3
OS Windows 10

What are the steps to reproduce this issue?

Create a Lua file with the following content:

---@alias set<x> table<x,any>

---@generic T
---@param value set<T>
---@return set<T>
local function identity(value)
    return value
end

---@type set<set<number>>
local aSet = {}

---@type set<set<number>>
local bSet = identity(aSet)

Maintainer Edit: Minimal Reproduction

---@alias set<x> table<x,any>

---@type set<set<number>>
local aSet

aSet = aSet

What happens?

Luanalysis generates a "Type mismatch" error on line local bSet = identity(aSet):

Type mismatch. Required: 'set<set<number>>' Found: 'set<table<number, any>>'

image

What were you expecting to happen?

No error: this should be a valid assign.

Any logs, error output, etc?

None

Any other comments?

The problem seems to only happen with alias types involved. The following lines do not generate an error

---@type set<table<number,any>>
local cSet = identity(aSet)
---@type table<table<number,any>,any>>
local cSet = identity(aSet)
@vsaulue vsaulue changed the title Unexpected type mismatch when assigning a generic function. Unexpected type mismatch with alias types. Jun 22, 2021
@Benjamin-Dobell Benjamin-Dobell added the bug Something isn't working label Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants