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

GDScript editor autocompletion is displaying the wrong type for a defined variable #92566

Open
rcanpahali opened this issue May 30, 2024 · 3 comments · May be fixed by #92584
Open

GDScript editor autocompletion is displaying the wrong type for a defined variable #92566

rcanpahali opened this issue May 30, 2024 · 3 comments · May be fixed by #92584

Comments

@rcanpahali
Copy link

Tested versions

  • Reproducable in Godot Engine v4.2.2.stable.official [15073af]

System information

Apple M1 Pro - macOS 14.5 (23F79)

Issue description

I already defined my npc variable as a PackedScene in the line 6, but for some reason, the editor IntelliSense in the suggestions shows its type as any, and I couldn't see the actual methods related to the PackedScene.

npc.instantiate() method is working fine but the method is not shown in the auto-complete list,

image

Steps to reproduce

To reproduce the steps, simply create a script as follows:

extends Node2D

@export var npc_list: Array[PackedScene]

func spawn_npc() -> void:
	var npc: PackedScene = npc_list.pick_random()
	var new_npc = npc.instantiate()

Minimal reproduction project (MRP)

Archive.zip

@HolonProduction
Copy link
Member

HolonProduction commented May 31, 2024

#85224 should have fixed that but I made an oversight. We use the analyzer logic to test whether the assigned type is compatible. The analyzer allows assigning variant types to everything, and pick_random returns a variant which for the analyzer is compatible with PackedScene (though unsave). So we end up with the type of the assigned expression but a variant doesn't has much value for autocompletion.

Edit: Just to clarify this any icon is used for all local variables at the moment. The type of the variable has no influence on it. I consider the scope of this issue to be the not working autocompletion. It might make sense to create a separate issue to request a better icon for local variables though.

@github-project-automation github-project-automation bot moved this to For team assessment in GDScript Issue Triage Jun 4, 2024
@dalexeev dalexeev moved this from For team assessment to Fix pending review in GDScript Issue Triage Jun 4, 2024
@dalexeev dalexeev added this to the 4.3 milestone Jun 4, 2024
@Joseph-D-Bradshaw
Copy link

Not sure if related, but I realise that type hints are not working (also giving me "any", which I see is not an issue here).

But for example.

var mesh: MeshInstance3D = get_child(0)
mesh.get_surface_override_material(0)  # this gives no autocompletion

I find that I am needing to use the as keyword a lot to get autocompletion to work.

@HolonProduction
Copy link
Member

Not sure if related, but I realise that type hints are not working (also giving me "any", which I see is not an issue here).

As long as you are still on 4.2 no need to worry, #85224 should've fixed that. If you are using 4.3 please open an issue with an MRP about it.

@Calinou Calinou changed the title GDScript editor IntelliSense is displaying the wrong type for a defined variable GDScript editor autocompletion is displaying the wrong type for a defined variable Jul 11, 2024
@dalexeev dalexeev modified the milestones: 4.3, 4.4 Jul 24, 2024
@AThousandShips AThousandShips removed this from the 4.4 milestone Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Fix pending review
Development

Successfully merging a pull request may close this issue.

6 participants