-
-
Notifications
You must be signed in to change notification settings - Fork 21.8k
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 cannot infer the type of a variable initialized with a typed method call #68069
Comments
I confirm the issue for Godot 4.0. |
Still getting the same error messages in Godot 4 beta 7. |
I'd be pretty excited to take a look at this one if no one else is. Recently did a little bit of work on initializers so it's a part of the code I'm not completely clueless on :) |
i'm sorry to do this to you again @anvilfolk, but my out of order member resolution branch fixes this |
For a moment I thought this was for a PR that I had already submitted! It isn't, and no worries even if it was :) I started looking into it a little bit but didn't get super far. It makes a ton of sense that PR would fix it! Curious how you did it! I'm guessing something like parsing non-inferred types or functions first, and inferred types later? |
@anvilfolk i typed up an explanation and thought i sent it, but now its eaten by my browser :(, my PR has a bit if an explanation, and ill flesh it out a bit more :) |
Sweet, thank you. It is mostly curiosity, and I'm trying to review the PR now so it gets more upvotes to get merged sooner rather than later! :) |
So I had this problem show up again for me, using the Godot_v4.0.2-stable_linux.x86_64 build. I loaded the FPS engine template and tried to run it, and got: |
What is the type of And just to note, the bug is about a typed method call. In your example, there's no method to be seen. |
Godot version
v4.0.beta3.official [01ae26d]
System information
KDE neon 22.04
Issue description
(Sorry in advance if the following bug was reported before, or is already fixed. I couldn't find anything related.)
(Edit: Added the MRP.)
It seems that the GDScript parser cannot infer the type of a typed user method ahead of its definition.
The code above will trigger a parser error notification on both the script editor and the debug console, as follows:
For comparison: that same code works on Godot 3.5.
Either declaring the variable after the method or replacing the type inferred assignment (
:=
) works fine.Steps to reproduce
Creating a script with the following content on any project triggers the error:
Minimal reproduction project
68069.zip
The text was updated successfully, but these errors were encountered: