IntelliJ-Luanalysis icon indicating copy to clipboard operation
IntelliJ-Luanalysis copied to clipboard

Type mismatch. Required: 'string' Found: '[global name] | string'

Open LelouBil opened this issue 3 years ago • 0 comments

Environment

Name Version
IDEA version RD-213.6461.51
Luanalysis version 1.2.2
OS Windows 10

Preferences

(Preferences -> Languages & Frameworks > Luanalysis)

Lua

Name Setting
Language level Lua 5.2

Type Safety

Name Setting
Strict nil checks ☑️
Unknown type (any) is indexable
Unknown type (any) is callabale

What are the steps to reproduce this issue?

  1. Create a global variable with string type and string type annotation
  2. Try to pass it as argument of a function that wants a string

What happens?

image

What were you expecting to happen?

The parameter to be accepted

Any logs, error output, etc?

Any other comments?

It may be because I don't know Lua very much, but I'm not sure why a global variable of type string is typed differently than a local variable of type string. Moreover, if I use a type cast (--[[---@type string]]) it works, and I don't understand why it changes anything.

Or maybe this is due to the fact that there are other files in the project that assign to the same global variable ? They are also all assigning strings.

LelouBil avatar Jan 17 '22 07:01 LelouBil