GDScript: Disallow return with value in void functions

This commit is contained in:
Dmitrii Maganov
2022-12-28 07:12:16 +02:00
parent 7e1bd3f95a
commit 9507f65e25
7 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,2 @@
func test() -> void:
return null

View File

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
A void function cannot return a value.

View File

@ -0,0 +1,4 @@
func test() -> void:
var a
a = 1
return a

View File

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
A void function cannot return a value.

View File

@ -0,0 +1,5 @@
func variant() -> Variant:
return 'variant'
func test():
print(variant())

View File

@ -0,0 +1,2 @@
GDTEST_OK
variant