You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GDScript : Calling another static function inside a static function from a script calls its parent script's function instead of its own script's.
#59280
In GDScript, when calling a static funtion from a script, or an instance of this script, which extends a parent script, you call the function from its * own * script, (instead of its parent script).
So in GDScript, static functions are polymorphic.
Similarly, when calling a static function from an instance of the script, if this static function func_a calls another static function func_b, func_a will call func_b from its * own * script , (instead of its parent script), too.
However, when calling the same static function from the script (instead of an instance), func_a will call the function func_b from its * parent * script, (rather than from its own script).
It doesn't seem quite consistent.
Steps to reproduce
toolextendsEditorScriptclassPerson:
staticfuncget_breath_skill_level():
return0staticfuncget_pitch_accuracy():
return1staticfuncget_sing_skill_level():
returnget_breath_skill_level() +get_pitch_accuracy()
funcbreath():
print("breath ordinarily,")
funcsing():
breath()
print("and sing.")
classSinger:
extendsPersonstaticfuncget_breath_skill_level():
return5staticfuncget_pitch_accuracy():
return5funcbreath():
print("breath professionally,")
func_run():
varsinger_1:=Singer.new()
singer_1.sing() # can breath professionallyprint("singer_1's sing skill level == ", singer_1.get_breath_skill_level()) # prints 5print("singer_1's sing skill level == ", singer_1.get_sing_skill_level()) # prints 10print("Singer's breath level == ", Singer.get_breath_skill_level()) # prints 5print("Singer's sing level == ", Singer.get_sing_skill_level()) # prints 1
Minimal reproduction project
No response
The text was updated successfully, but these errors were encountered:
Godot version
3.5 beta2
System information
Windows 10
Issue description
In GDScript, when calling a static funtion from a script, or an instance of this script, which extends a parent script, you call the function from its * own * script, (instead of its parent script).
So in GDScript, static functions are polymorphic.
Similarly, when calling a static function from an instance of the script, if this static function
func_a
calls another static functionfunc_b
,func_a
will callfunc_b
from its * own * script , (instead of its parent script), too.However, when calling the same static function from the script (instead of an instance),
func_a
will call the functionfunc_b
from its * parent * script, (rather than from its own script).It doesn't seem quite consistent.
Steps to reproduce
Minimal reproduction project
No response
The text was updated successfully, but these errors were encountered: