summaryrefslogtreecommitdiff
path: root/modules/gdscript/tests/scripts/analyzer/errors
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-01-03 12:20:33 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-01-03 12:20:33 +0100
commite4c1103af49b27dde003a03a8ac20aaa33495bd4 (patch)
treed47c07c3be87409bdaddf1a0d96aa1ff7588c452 /modules/gdscript/tests/scripts/analyzer/errors
parent6d7f6c1eb9ca2eb3c94a91f8c5497577997de03a (diff)
parent9507f65e25fd02b1e5817b787afdbef334b964e7 (diff)
Merge pull request #70656 from vonagam/fix-void-returns
GDScript: Disallow return with value in void functions
Diffstat (limited to 'modules/gdscript/tests/scripts/analyzer/errors')
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.gd2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.gd4
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.out2
4 files changed, 10 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.gd b/modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.gd
new file mode 100644
index 0000000000..63587942f7
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.gd
@@ -0,0 +1,2 @@
+func test() -> void:
+ return null
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.out b/modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.out
new file mode 100644
index 0000000000..3c09f44ba9
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+A void function cannot return a value.
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.gd b/modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.gd
new file mode 100644
index 0000000000..0ee4e7ea36
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.gd
@@ -0,0 +1,4 @@
+func test() -> void:
+ var a
+ a = 1
+ return a
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.out b/modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.out
new file mode 100644
index 0000000000..3c09f44ba9
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+A void function cannot return a value.