-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
A nested class cannot access function outside its scope #4472
Comments
|
Also, the completion shows |
This is normal, as Godot do not implement closures. |
If you want closures to be added, just add proper request. And send PR fixing it. |
Inner class is not a subclass, so it's expected that it doesn't have access to the outer class' methods. I would propose to add a way to reference the outer class, so you can explicitly make use of inheritance and access static methods. |
I confirm that it's a bug, actually the inner class has access to its outer class' functions if it's place at the end of the file. If place at the beginning, it can only see the outer constants, but all the rest will be seen as undefined. |
Nevermind, looks like I misinterpreted the situation in my script, even when placed at the end of the file the inner class does not have access to its outer class' functions and member variables, only constants. |
In any case, static functions should be accessible by all inner classes, since it is currently impossible to do it without a recursive load or preload... |
@bojidar-bg you can give it a try if you want, meanwhile I will kick to 3.1 |
I suspect this is related with a few other problematic cases (and in general with the order of traversing the script):
EDIT: |
Moving to the next milestone as 3.1 is now feature frozen. |
Will this work in Godot 4 trough use of the new callable type ? |
Callable doesn't help with this. As I mention, we either need some way to reference the outer class or automatically resolve the static method in the compiler (like it does with constants). But yes, I intend to work on this for 4.0. |
Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine. The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker. If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance! |
...With or without
static
keyword.well I think it should.
The text was updated successfully, but these errors were encountered: