diff options
author | George Marques <george@gmarqu.es> | 2023-01-27 17:54:07 -0300 |
---|---|---|
committer | George Marques <george@gmarqu.es> | 2023-01-31 11:37:30 -0300 |
commit | a47d4d57cac7077c9ad1c63f27ea095e6ce73561 (patch) | |
tree | 06827a629729218dda7f0d49d496c4147c927923 /modules/gdscript/tests/scripts/analyzer | |
parent | e1648b3327431a09cc9498663fac483275eb711d (diff) |
GDScript: Allow void functions to return calls to other void functions
Diffstat (limited to 'modules/gdscript/tests/scripts/analyzer')
-rw-r--r-- | modules/gdscript/tests/scripts/analyzer/features/allow_void_function_to_return_void.gd | 20 | ||||
-rw-r--r-- | modules/gdscript/tests/scripts/analyzer/features/allow_void_function_to_return_void.out | 10 |
2 files changed, 30 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/analyzer/features/allow_void_function_to_return_void.gd b/modules/gdscript/tests/scripts/analyzer/features/allow_void_function_to_return_void.gd new file mode 100644 index 0000000000..df89137f40 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/allow_void_function_to_return_void.gd @@ -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") diff --git a/modules/gdscript/tests/scripts/analyzer/features/allow_void_function_to_return_void.out b/modules/gdscript/tests/scripts/analyzer/features/allow_void_function_to_return_void.out new file mode 100644 index 0000000000..7c0416371f --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/allow_void_function_to_return_void.out @@ -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 |