GDScript: Error when assigning return value of void function

This also makes built-in method calls empty the return value when the
method is void, to avoid keeping returning a garbage value in such case.
This commit is contained in:
George Marques
2022-12-29 08:57:41 -03:00
parent b6e06038f8
commit 0c15844551
10 changed files with 70 additions and 18 deletions
@@ -0,0 +1,4 @@
func test():
var obj
obj = Node.new()
print(obj.free())
@@ -0,0 +1,6 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR
>> on function: test()
>> runtime/errors/use_return_value_of_free_call.gd
>> 4
>> Trying to get a return value of a method that returns "void"
@@ -0,0 +1,4 @@
func test():
var value
value = []
print(value.reverse())
@@ -0,0 +1,6 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR
>> on function: test()
>> runtime/errors/use_return_value_of_void_builtin_method_call.gd
>> 4
>> Trying to get a return value of a method that returns "void"
@@ -0,0 +1,4 @@
func test():
var obj
obj = RefCounted.new()
print(obj.notify_property_list_changed())
@@ -0,0 +1,6 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR
>> on function: test()
>> runtime/errors/use_return_value_of_void_native_method_call.gd
>> 4
>> Trying to get a return value of a method that returns "void"