-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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: Adjust STATIC_CALLED_ON_INSTANCE
warning to not force native type
#85918
GDScript: Adjust STATIC_CALLED_ON_INSTANCE
warning to not force native type
#85918
Conversation
STATIC_CALLED_ON_INSTANCE
warning to not force native type
Note that for non-global classes the warning will suggest invalid code. |
Example, please? I'm not sure what constitutes a "non-global class" in this case. |
Note that this would be wrong on the current master also, it would show We can either accept this as small improvement or work on a proper fix that finds the origin of method. PS: I wonder if we should even emit this warning with a direct call for a function in the same class. If it does not have |
3434530
to
e6fe75b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me, although the point about non-global classes still applies.
modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.gd
Show resolved
Hide resolved
modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.out
Show resolved
Hide resolved
…the native type, and to not trigger on self-calls Not defaulting to the native type rationale: Defaulting to the native type is less than useful, as: * There are very few native types that are extensible and have static methods. * Defaulting to the native type does not account for a method being script-defined. While the "real fix" would be to carefully track the source of the method, the get_function_signature method is already complicated enough. This will at least ensure the resulting code should always be valid. Not triggering on self-calls rationale: Found in PR comment godotengine#85918 (comment) ``` static func example(): pass func example2(): example() # self-call on static function ``` Disabling this warning on self-calls is: * Consistent with other languages * Important for anonymous classes (where the output code is unusable)
e6fe75b
to
24181d1
Compare
Thanks! |
Defaulting to the native type is less than useful, as:
While the "real fix" would be to carefully track the source of the method, the get_function_signature method is already complicated enough.
This will at least ensure the resulting code should always be valid.
This PR was written after seeing the following warning:
Where
get_absolute_z_index()
was a static function declared in a script (and thus did not exist in Node2D, and thus the given code did not work)