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

Literal alias will throw false alarm #1684

Closed
evan361425 opened this issue Nov 10, 2022 · 1 comment
Closed

Literal alias will throw false alarm #1684

evan361425 opened this issue Nov 10, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@evan361425
Copy link
Contributor

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

MacOS

What is the issue affecting?

Annotations, Type Checking

Expected Behaviour

Follow the wiki tutorial:

local A = "Hello"
local B = "World"

---@alias myLiteralAliases `A` | `B`

---@param x myLiteralAliases
function foo(x) end

it should not show any warning when using it:

foo(A)

Actual Behaviour

It show warning:

Cannot assign `string` to parameter ``A`|`B``.
- `string` cannot match ``A`|`B``Lua Diagnostics.(param-type-mismatch)

Screen Shot 2022-11-10 at 11 42 56 AM

Reproduction steps

Enter the code in VSCode

local A = "Hello"
local B = "World"

---@alias myLiteralAliases `A` | `B`

---@param x myLiteralAliases
function foo(x) end

foo(A)

then you will see it

Additional Notes

Some info:

$ code --version
1.73.0
8fa188b2b301d36553cbc9ce1b0a146ccb93351f
x64
$ ls ~/.vscode/extensions/ | grep sumneko
sumneko.lua-3.6.2-darwin-x64

Log File

No response

@sumneko sumneko added the bug Something isn't working label Nov 10, 2022
@evan361425
Copy link
Contributor Author

holy efficency

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