From 056a54db7be5b63685f221e34c17cc4b72964080 Mon Sep 17 00:00:00 2001 From: George Marques Date: Thu, 14 Oct 2021 19:58:10 -0300 Subject: GDScript: Properly return value with await on non-coroutine If the keyword `await` is used without a coroutine, it should still return the value synchronally. --- .../tests/scripts/runtime/features/await_without_coroutine.gd | 8 ++++++++ .../tests/scripts/runtime/features/await_without_coroutine.out | 6 ++++++ 2 files changed, 14 insertions(+) create mode 100644 modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.gd create mode 100644 modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.out (limited to 'modules/gdscript/tests') diff --git a/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.gd b/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.gd new file mode 100644 index 0000000000..9da61ab184 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.gd @@ -0,0 +1,8 @@ +# https://github.com/godotengine/godot/issues/50894 + +func test(): + print(await not_coroutine()) + + +func not_coroutine(): + return "awaited" diff --git a/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.out b/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.out new file mode 100644 index 0000000000..c2ac488e9b --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.out @@ -0,0 +1,6 @@ +GDTEST_OK +>> WARNING +>> Line: 4 +>> REDUNDANT_AWAIT +>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. +awaited -- cgit v1.2.3