Skip to content

Undefined field with "string" type hinted variables #566

@Avril112113

Description

@Avril112113

Describe the bug
With a variable or function parameter that has been given typing info to be a "string", undefined field warnings show for any field access on that variable/paremter.
I have been unable to find a test case with other built-in types, but it works as expected for custom types

To Reproduce
Steps to reproduce the behavior:

  1. In code, access any field on a "string" typed variable
  2. "Undefined field" warning will show up on that field

Code shown in below screenshot

---@type string
local strTyped
print(strTyped:lower())
print(strTyped:len())
print(strTyped.upper(strTyped))

-- Working as expected
local strInferred = "Foo"
print(strInferred:lower())
print(strInferred:len())
print(strInferred.upper(strInferred))

Expected behavior
"Undefined field" to not show up on "string" typed variable fields that do exist.

Screenshots
image

Environment (please complete the following information):

  • OS: Windows
  • Client: VSCode

Additional context
This is using the new 2.0.0 version of the extension.

Provide logs
https://pastebin.com/8s8sNPJC
There seems to be 2 of the same erros in the log that could be related at lines 3392 and 3589
Apologies for the long log file...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority.highA high priority topic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions