diff options
author | Nathan Franke <me@nathan.sh> | 2022-06-03 12:42:03 -0500 |
---|---|---|
committer | Nathan Franke <me@nathan.sh> | 2022-06-03 13:28:33 -0500 |
commit | 3d61246bc4bce185dcdfc156945085456fbad402 (patch) | |
tree | bd3af93e2b73e66533562581fd705bfa65ea3b43 /modules/gdscript/tests/scripts | |
parent | c0bf18e92398c0d5a9cc3a9c51073ddcc5224b65 (diff) |
use correct error for unused bind match, suppress with underscore
Diffstat (limited to 'modules/gdscript/tests/scripts')
-rw-r--r-- | modules/gdscript/tests/scripts/parser/features/match_bind_unused.gd | 13 | ||||
-rw-r--r-- | modules/gdscript/tests/scripts/parser/features/match_bind_unused.out | 6 |
2 files changed, 19 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/parser/features/match_bind_unused.gd b/modules/gdscript/tests/scripts/parser/features/match_bind_unused.gd new file mode 100644 index 0000000000..707e4532cc --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/features/match_bind_unused.gd @@ -0,0 +1,13 @@ +# https://github.com/godotengine/godot/pull/61666 + +func test(): + var dict := {"key": "value"} + match dict: + {"key": var value}: + print(value) # used, no warning + match dict: + {"key": var value}: + pass # unused, warning + match dict: + {"key": var _value}: + pass # unused, suppressed warning from underscore diff --git a/modules/gdscript/tests/scripts/parser/features/match_bind_unused.out b/modules/gdscript/tests/scripts/parser/features/match_bind_unused.out new file mode 100644 index 0000000000..057c1b11e5 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/features/match_bind_unused.out @@ -0,0 +1,6 @@ +GDTEST_OK +>> WARNING +>> Line: 9 +>> UNUSED_VARIABLE +>> The local variable 'value' is declared but never used in the block. If this is intended, prefix it with an underscore: '_value' +value |