godotengine / godot-vscode-plugin

Godot development tools for VSCode
MIT License
1.52k stars 149 forks source link

Could not find type in the current scope. #487

Open michaelschufi opened 1 year ago

michaelschufi commented 1 year ago

Godot version

v4.1.1.stable.official [bd6af8e0e]

VS Code version

1.81.1

Godot Tools VS Code extension version

1.3.1

System information

Windows 10

Issue description

The VS Code extension shows an error that the type (class in this case) cannot be found if the class name is used in the type definition. The Godot Editor can resolve the class without issue.

VS Code: image

Godot Editor: image

Steps to reproduce

  1. Create a script called _entity.gd.
  2. Make it extend a class and give it a class name class_name Entity
  3. Make a second script
  4. in the second script, use the class name Entity in a type annotation of a function parameter.
atirut-w commented 1 year ago

This looks like a bug on the LSP side of things.

BeyondXinXin commented 11 months ago

I always encounter this problem, especially when creating files with inheritance relationships in vscode. I need to restart the Godot engine frequently to get the correct prompts and warnings.

ainformatico commented 11 months ago

Just encountered the same issue. I see reports back from 2020 of the same issue. Couple of issues in this repo already, https://github.com/godotengine/godot-vscode-plugin/issues/266 and https://github.com/godotengine/godot-vscode-plugin/issues/431

The outcome seems to be: seems like a LSP bug.

The workaround that also found is the same as @BeyondXinXin :

I need to restart the Godot engine frequently to get the correct prompts and warnings.

For future reference, I'm posting this in the existing issue on the Godot engine: https://github.com/godotengine/godot/issues/80822

DaelonSuzuka commented 6 months ago

The outcome seems to be: seems like a LSP bug.

100% an LSP bug.

This sort of thing happens less often for me in Godot 4.2+.