summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/tests/scripts/parser
diff options
context:
space:
mode:
authorGeorge Marques <george@gmarqu.es>2024-04-17 09:40:58 -0300
committerGeorge Marques <george@gmarqu.es>2024-04-18 09:58:23 -0300
commita3b3a20ac0069046c68be47b16be1a9b92bdda1d (patch)
tree5462d32c32ef9f1c498a1ca0da3cc833561e909e /modules/gdscript/tests/scripts/parser
parent658e97c93aa2533cb7b12f05e62dcf6864e7acbe (diff)
downloadredot-engine-a3b3a20ac0069046c68be47b16be1a9b92bdda1d.tar.gz
GDScript: Suppress unused constant warning with underscore
The warning message mentions that local constants prefixed with `_` does not generate the warning. This commit actually implements this warning suppression.
Diffstat (limited to 'modules/gdscript/tests/scripts/parser')
-rw-r--r--modules/gdscript/tests/scripts/parser/features/constants.out32
-rw-r--r--modules/gdscript/tests/scripts/parser/features/static_typing.out20
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/unused_constant.gd4
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/unused_constant.out5
4 files changed, 9 insertions, 52 deletions
diff --git a/modules/gdscript/tests/scripts/parser/features/constants.out b/modules/gdscript/tests/scripts/parser/features/constants.out
index 7ec33470d3..d73c5eb7cd 100644
--- a/modules/gdscript/tests/scripts/parser/features/constants.out
+++ b/modules/gdscript/tests/scripts/parser/features/constants.out
@@ -1,33 +1 @@
GDTEST_OK
->> WARNING
->> Line: 2
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_TEST" is declared but never used in the block. If this is intended, prefix it with an underscore: "__TEST".
->> WARNING
->> Line: 3
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_STRING" is declared but never used in the block. If this is intended, prefix it with an underscore: "__STRING".
->> WARNING
->> Line: 4
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_VECTOR" is declared but never used in the block. If this is intended, prefix it with an underscore: "__VECTOR".
->> WARNING
->> Line: 5
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_ARRAY" is declared but never used in the block. If this is intended, prefix it with an underscore: "__ARRAY".
->> WARNING
->> Line: 6
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_DICTIONARY" is declared but never used in the block. If this is intended, prefix it with an underscore: "__DICTIONARY".
->> WARNING
->> Line: 9
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_HELLO" is declared but never used in the block. If this is intended, prefix it with an underscore: "__HELLO".
->> WARNING
->> Line: 10
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_INFINITY" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INFINITY".
->> WARNING
->> Line: 11
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_NOT_A_NUMBER" is declared but never used in the block. If this is intended, prefix it with an underscore: "__NOT_A_NUMBER".
diff --git a/modules/gdscript/tests/scripts/parser/features/static_typing.out b/modules/gdscript/tests/scripts/parser/features/static_typing.out
index 40a8f97416..d73c5eb7cd 100644
--- a/modules/gdscript/tests/scripts/parser/features/static_typing.out
+++ b/modules/gdscript/tests/scripts/parser/features/static_typing.out
@@ -1,21 +1 @@
GDTEST_OK
->> WARNING
->> Line: 11
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_INTEGER" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER".
->> WARNING
->> Line: 12
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_INTEGER_REDUNDANT_TYPED" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER_REDUNDANT_TYPED".
->> WARNING
->> Line: 13
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_INTEGER_REDUNDANT_TYPED2" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER_REDUNDANT_TYPED2".
->> WARNING
->> Line: 14
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_INTEGER_REDUNDANT_INFERRED" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER_REDUNDANT_INFERRED".
->> WARNING
->> Line: 15
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_INTEGER_REDUNDANT_INFERRED2" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER_REDUNDANT_INFERRED2".
diff --git a/modules/gdscript/tests/scripts/parser/warnings/unused_constant.gd b/modules/gdscript/tests/scripts/parser/warnings/unused_constant.gd
new file mode 100644
index 0000000000..3d355197e1
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/warnings/unused_constant.gd
@@ -0,0 +1,4 @@
+func test():
+ const UNUSED = "not used"
+
+ const _UNUSED = "not used, but no warning since the constant name starts with an underscore"
diff --git a/modules/gdscript/tests/scripts/parser/warnings/unused_constant.out b/modules/gdscript/tests/scripts/parser/warnings/unused_constant.out
new file mode 100644
index 0000000000..99ced48433
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/warnings/unused_constant.out
@@ -0,0 +1,5 @@
+GDTEST_OK
+>> WARNING
+>> Line: 2
+>> UNUSED_LOCAL_CONSTANT
+>> The local constant "UNUSED" is declared but never used in the block. If this is intended, prefix it with an underscore: "_UNUSED".