1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-13 13:31:48 +00:00

GDScript: Allow void functions to return calls to other void functions

This commit is contained in:
George Marques
2023-01-27 17:54:07 -03:00
parent e1648b3327
commit a47d4d57ca
8 changed files with 78 additions and 10 deletions

View File

@@ -0,0 +1,20 @@
func test():
return_call()
return_nothing()
return_side_effect()
var r = return_side_effect.call() # Untyped call to check return value.
prints(r, typeof(r) == TYPE_NIL)
print("end")
func side_effect(v):
print("effect")
return v
func return_call() -> void:
return print("hello")
func return_nothing() -> void:
return
func return_side_effect() -> void:
return side_effect("x")

View File

@@ -0,0 +1,10 @@
GDTEST_OK
>> WARNING
>> Line: 20
>> UNSAFE_VOID_RETURN
>> The method 'return_side_effect()' returns 'void' but it's trying to return a call to 'side_effect()' that can't be ensured to also be 'void'.
hello
effect
effect
<null> true
end