godotengine / godot

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

Autocompletion of animation names stops working when type hints are added to AnimationPlayer, AnimatedSprite2D and AnimatedSprite3D variables in GDScript #92219

Open RayJJ opened 3 months ago

RayJJ commented 3 months ago

Tested versions

Reproducible in 4.2.2.stable and 4.3.dev6. Was present before 4.2.2 but first appearance not established. Occurs in both MacOS 14 and Windows 11.

System information

Godot v4.2.2.stable - macOS 14.4.1 - Vulkan (Forward+) - integrated Apple M1 - Apple M1 (8 Threads)

Issue description

Adding type hints to variables referencing AnimationPlayer, AnimatedSprite2D and AnimatedSprite3D prevents autocompletion from showing available animation names when editing their respective play() functions. This is true if the type hints are added manually and also if added automatically by Godot when 'add_type_hints' is set true in Editor Settings. Inferring types with ":=" and using dynamic typing does not prevent autocompletion.

Steps to reproduce

Add an AnimationPlayer, AnimatedSprite2D and AnimatedSprite3D to an empty scene. Assign the node to an @onready variable. Add a line of code in any GDScript function to call the play() function of the instantiated node. Note the presence / absence of autocompletion lists of animation names when the @onready declaration assumes a dynamic type or infers a type compared with when it has a type hint.

Minimal reproduction project (MRP)

automplete_problem_test.zip

RayJJ commented 3 months ago

Added note: For anyone that has been puzzled, as I was, by the lack of, or disappearance of, autocompletion lists on these nodes, the workaround for me was simple: just delete their type hints and autocomplete works as expected.

matheusmdx commented 3 months ago

Bisecting points to commit 6f8cc1b8deafa6d7e2ddc22dc71fff672b491f90 (added in #85784) / #79386 as the culprit:

image

dalexeev commented 3 months ago

^^ CC @HolonProduction

HolonProduction commented 3 months ago

This is the second regression on this PR, it's haunting me T_T

To suggest argument options, we need the value of the get node literal but since #79386 we drop it all together if a type was annotated. This should probably only happen if the value has a different type

RayJJ commented 3 months ago

Thank you everyone. That was a really impressive turnaround time.