From 685db28e2920150737bc53d5c86dcc64cc42bb60 Mon Sep 17 00:00:00 2001 From: Danil Alexeev Date: Fri, 3 Feb 2023 20:51:00 +0300 Subject: GDScript: Fix `await` type inference --- .../scripts/analyzer/errors/await_signal_no_infer.gd | 4 ++++ .../scripts/analyzer/errors/await_signal_no_infer.out | 2 ++ .../scripts/analyzer/features/await_type_inference.gd | 15 +++++++++++++++ .../scripts/analyzer/features/await_type_inference.out | 2 ++ 4 files changed, 23 insertions(+) create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.out create mode 100644 modules/gdscript/tests/scripts/analyzer/features/await_type_inference.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/features/await_type_inference.out (limited to 'modules/gdscript/tests') diff --git a/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.gd b/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.gd new file mode 100644 index 0000000000..c787d9e50e --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.gd @@ -0,0 +1,4 @@ +signal my_signal() + +func test(): + var _a := await my_signal diff --git a/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.out b/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.out new file mode 100644 index 0000000000..8f8744ad7e --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Cannot infer the type of "_a" variable because the value doesn't have a set type. diff --git a/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.gd b/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.gd new file mode 100644 index 0000000000..9d8cfc7f99 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.gd @@ -0,0 +1,15 @@ +func coroutine() -> int: + @warning_ignore("redundant_await") + await 0 + return 1 + +func not_coroutine() -> int: + return 2 + +func test(): + var a := await coroutine() + @warning_ignore("redundant_await") + var b := await not_coroutine() + @warning_ignore("redundant_await") + var c := await 3 + prints(a, b, c) diff --git a/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.out b/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.out new file mode 100644 index 0000000000..2920e2ce9c --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.out @@ -0,0 +1,2 @@ +GDTEST_OK +1 2 3 -- cgit v1.2.3