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

No autocompletion despite static typing #73638

Closed
CappedMonke opened this issue Feb 20, 2023 · 8 comments · Fixed by #79386
Closed

No autocompletion despite static typing #73638

CappedMonke opened this issue Feb 20, 2023 · 8 comments · Fixed by #79386

Comments

@CappedMonke
Copy link

Godot version

Godot 4.0 RC 2

System information

Windows 11

Issue description

As the title states you get no autocompletion when statically typing.
Of course the code still works, but it shouldn't be neccessary to cast an object to a type it already is.

Steps to reproduce

  1. Create child class with some functionality
    image

  2. Get node in parent class and call childs function
    image

Minimal reproduction project

N/A

@poohcom1
Copy link
Contributor

poohcom1 commented Feb 23, 2023

I think this is specific to auto-completion for variables obtained through get_node. There's a feature where the editor will provide auto-completion for relative node based on the currently opened scene, but it seems like it's incorrectly overriding the static typing in this case:

Without get_node With get_node
image image

I still get auto-completion though, just not for ChildClass, but for Node2D since that's the type of the node being referenced. Is this also the case for you, or are you just not getting any auto-completion at all?

If so, then the main issue here is that auto-completion from get_node has higher precedence than static typing auto-completion, which shouldn't be the case. Ideally static typing should take precedence, or the results could be combined.

@CappedMonke
Copy link
Author

CappedMonke commented Feb 26, 2023

Yes, you still get the Node2D auto-completion.
As you said static typing should take precedence.

@sam-s4s
Copy link

sam-s4s commented Mar 24, 2023

I came here to add this issue, but luckily found this first. Seems quite important to me, as a newcomer to Godot.

The first thing I tried to do was type some things in the tutorial, and it failed straight away.

var mob_spawn_location: PathFollow2D = get_node("MobPath/MobSpawnLocation")
mob_spawn_location.progre # autocomplete should give you .progress_ratio here, but it does not

Current workaround is to override the type from get_node, as described above...

var mob_spawn_location := get_node("MobPath/MobSpawnLocation") as PathFollow2D

But it is confusing and catches newbies like me out :P

@strangebirds
Copy link

I can confirm also present in Mac (Monterey) on Godot 4.01

@0Volcanon
Copy link

Just ran into this problem on Godot 4.0.2 while writing some tool scripts. The problem only seems to exist for the variables defined outside of the functions. If the hint is provided inside the function, it works fine. This problem did not exist in Godot 3.5.2.

@sam-s4s
Copy link

sam-s4s commented Apr 5, 2023

Just ran into this problem on Godot 4.0.2 while writing some tool scripts. The problem only seems to exist for the variables defined outside of the functions. If the hint is provided inside the function, it works fine. This problem did not exist in Godot 3.5.2.

My example above is all happening inside a function func _on_MobTimer_timeout():

(as per the https://docs.godotengine.org/en/3.5/getting_started/first_3d_game/05.spawning_mobs.html tutorial)

@0Volcanon
Copy link

I checked and it existed in 3.5 and 3.5.1 and was fixed in 3.5.2. #48037

@mbrlabs
Copy link
Contributor

mbrlabs commented Jul 2, 2023

In addition to @poohcom1's comment:

I think this is specific to auto-completion for variables obtained through get_node

If you use get_node() or the short hand version you can get autocompletion in the script that is referencing it, but only if the scene for ChildClass is currently open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants