-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74949 from dalexeev/gds-fix-await-warning
GDScript: Fix false positive `REDUNDANT_AWAIT` warning
- Loading branch information
Showing
5 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,5 @@ func test(): | |
|
||
print("done") | ||
|
||
func regular_func(): | ||
func regular_func() -> int: | ||
return 0 |
53 changes: 53 additions & 0 deletions
53
modules/gdscript/tests/scripts/analyzer/warnings/redundant_await.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
signal my_signal() | ||
|
||
# CI cannot test async things. | ||
func test_signals(): | ||
await my_signal | ||
var t: Signal = my_signal | ||
await t | ||
|
||
func coroutine() -> void: | ||
@warning_ignore("redundant_await") | ||
await 0 | ||
|
||
func not_coroutine_variant(): | ||
pass | ||
|
||
func not_coroutine_void() -> void: | ||
pass | ||
|
||
func test(): | ||
const CONST_NULL = null | ||
var var_null = null | ||
var var_int: int = 1 | ||
var var_variant: Variant = 1 | ||
var var_array: Array = [1] | ||
|
||
await CONST_NULL | ||
await var_null | ||
await var_int | ||
await var_variant | ||
await var_array[0] | ||
|
||
await coroutine | ||
await coroutine() | ||
await coroutine.call() | ||
await self.coroutine() | ||
await call(&"coroutine") | ||
|
||
await not_coroutine_variant | ||
await not_coroutine_variant() | ||
await self.not_coroutine_variant() | ||
await not_coroutine_variant.call() | ||
await call(&"not_coroutine_variant") | ||
|
||
await not_coroutine_void | ||
await not_coroutine_void() | ||
await self.not_coroutine_void() | ||
await not_coroutine_void.call() | ||
await call(&"not_coroutine_void") | ||
|
||
var callable: Callable = coroutine | ||
await callable | ||
await callable.call() | ||
await callable.get_method() |
37 changes: 37 additions & 0 deletions
37
modules/gdscript/tests/scripts/analyzer/warnings/redundant_await.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
GDTEST_OK | ||
>> WARNING | ||
>> Line: 26 | ||
>> REDUNDANT_AWAIT | ||
>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. | ||
>> WARNING | ||
>> Line: 28 | ||
>> REDUNDANT_AWAIT | ||
>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. | ||
>> WARNING | ||
>> Line: 32 | ||
>> REDUNDANT_AWAIT | ||
>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. | ||
>> WARNING | ||
>> Line: 38 | ||
>> REDUNDANT_AWAIT | ||
>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. | ||
>> WARNING | ||
>> Line: 44 | ||
>> REDUNDANT_AWAIT | ||
>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. | ||
>> WARNING | ||
>> Line: 45 | ||
>> REDUNDANT_AWAIT | ||
>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. | ||
>> WARNING | ||
>> Line: 46 | ||
>> REDUNDANT_AWAIT | ||
>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. | ||
>> WARNING | ||
>> Line: 51 | ||
>> REDUNDANT_AWAIT | ||
>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. | ||
>> WARNING | ||
>> Line: 53 | ||
>> REDUNDANT_AWAIT | ||
>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ func test(): | |
print(await not_coroutine()) | ||
|
||
|
||
func not_coroutine(): | ||
func not_coroutine() -> String: | ||
return "awaited" |