godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.12k stars 21.19k forks source link

[3.x] No autocompletion for typed variables sometimes (fixed in `master`) #42005

Open KoBeWi opened 4 years ago

KoBeWi commented 4 years ago

Godot version:

3.2.3 rc6

Issue description:

onready var sprite := $Sprite as Sprite
onready var sprite2: Sprite = $Sprite

Autocompletion image No autocompletion image

What's even more weird, in my project I have a script where it's opposite (i.e. when type is assigned with as, the autocompletion fails)

KoBeWi commented 4 years ago

Ok so I found another similar case (screenshot from master): image image Even though I declared a variable with a type, I need to cast it explicitly when assigning, otherwise it uses wrong type (probably Node in this case).

greatmomo commented 3 years ago

I just wanted to add that this is still happening in 3.3.1 and in the 4.0 devel master

akien-mga commented 2 years ago

Fixed in master by #62760 but let's keep open if someone wants to attempt a similar fix for 3.x.

cdemirer commented 2 years ago

Ok so I found another similar case (screenshot from master):

By the way, I realized the fix in master doesn't fix the situation in this image since the type guesser uses the last assigned value type with more priority. This could be fixed again by tweaking the order of stuff in _guess_identifier_type(), but maybe we want it to combine the 2 instead (choose the more precise one)?