-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Non-static methods can't be referenced as Callables from static methods #91403
Comments
I think the old behavior is also incorrect, non-static members should not be accessible in a static context, there should be an analyzer error. If you try to call |
I was using it to obtain method name, i.e. btw I forgot to mention that the new error is runtime-only. It doesn't appear in the editor. |
Looking at the changelog, I suppose this might have been caused by #90223 ? |
Yes, most likely. But I think this is a valid assumption for the compiler, we should not allow static access to non-static members at the analyzer level. |
Yeah, the old behavior was wrong. For a Callable you need an object and a method name, but in a static constant there's no object. Maybe we can consider adding a Not showing the error in-editor is another issue and should be fixed too. |
I didn't test after the fix, because I assumed it was working, but seems like instead of allowing it, the fix just made the error appear in the editor too. Was that intended? |
@KoBeWi Yes, that's how it was intended. GDScript functions and |
Tested versions
4.3 dev6 broken
4.3 dev5 works
System information
Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1060 (NVIDIA; 31.0.15.4633) - Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 Threads)
Issue description
Running this script in dev5 prints
Node::not_static
. Running in dev6 results inInvalid access to property or key 'not_static' on a base object of type 'Nil'.
. The callable is not accessible even if you name the script and doClassName.not_static
.Steps to reproduce
Minimal reproduction project (MRP)
See above.
The text was updated successfully, but these errors were encountered: