GDScript: Add @warning_ignore_start and @warning_ignore_restore annotations

This commit is contained in:
Danil Alexeev
2024-12-06 10:25:59 +03:00
parent eb5103093c
commit 7d65d0a908
22 changed files with 221 additions and 89 deletions

View File

@@ -13,7 +13,7 @@ func param_inferred(param := variant()) -> void: print(param)
func return_untyped(): return variant()
func return_typed() -> Variant: return variant()
@warning_ignore("unused_variable", "inference_on_variant")
@warning_ignore_start("unused_variable", "inference_on_variant")
func test() -> void:
var weak = variant()
var typed: Variant = variant()
@@ -32,4 +32,4 @@ func test() -> void:
if typed != null: pass
if typed is Node: pass
print('ok')
print("ok")

View File

@@ -123,4 +123,4 @@ func test():
Utils.check((const_null is A) == false)
Utils.check(is_instance_of(const_null, A) == false)
print('ok')
print("ok")

View File

@@ -20,9 +20,7 @@ class Members:
Utils.check(str(two) == '[486]')
return true
@warning_ignore("unsafe_method_access")
@warning_ignore("return_value_discarded")
@warning_ignore_start('unsafe_method_access', 'return_value_discarded')
func test():
var untyped_basic = [459]
Utils.check(str(untyped_basic) == '[459]')
@@ -207,7 +205,7 @@ func test():
var a := A.new()
var typed_natives: Array[RefCounted] = [a]
var typed_scripts = Array(typed_natives, TYPE_OBJECT, "RefCounted", A)
var typed_scripts = Array(typed_natives, TYPE_OBJECT, 'RefCounted', A)
Utils.check(typed_scripts[0] == a)

View File

@@ -21,9 +21,7 @@ class Members:
return true
@warning_ignore("unsafe_method_access")
@warning_ignore("assert_always_true")
@warning_ignore("return_value_discarded")
@warning_ignore_start("unsafe_method_access", "return_value_discarded")
func test():
var untyped_basic = { 459: 954 }
Utils.check(str(untyped_basic) == '{ 459: 954 }')

View File

@@ -1,6 +1,6 @@
signal ok()
@warning_ignore("return_value_discarded")
@warning_ignore_start("return_value_discarded")
func test():
ok.connect(func(): print('ok'))
emit_signal(&'ok')
ok.connect(func(): print("ok"))
emit_signal(&"ok")

View File

@@ -1,6 +1,7 @@
GDTEST_OK
~~ WARNING at line 3: (CONFUSABLE_IDENTIFIER) The identifier "my_vАr" has misleading characters and might be confused with something else.
~~ WARNING at line 8: (NARROWING_CONVERSION) Narrowing conversion (float is converted to int and loses precision).
~~ WARNING at line 14: (NARROWING_CONVERSION) Narrowing conversion (float is converted to int and loses precision).
~~ WARNING at line 19: (NARROWING_CONVERSION) Narrowing conversion (float is converted to int and loses precision).
~~ WARNING at line 24: (NARROWING_CONVERSION) Narrowing conversion (float is converted to int and loses precision).
~~ WARNING at line 27: (CONFUSABLE_IDENTIFIER) The identifier "_my_vАr" has misleading characters and might be confused with something else.

View File

@@ -4,11 +4,10 @@ extends ShadowingBase
var member: int = 0
var print_debug := 'print_debug'
@warning_ignore("shadowed_global_identifier")
@warning_ignore('shadowed_global_identifier')
var print := 'print'
@warning_ignore("unused_variable")
@warning_ignore("unused_local_constant")
@warning_ignore_start('unused_variable', 'unused_local_constant')
func test():
var Array := 'Array'
var Node := 'Node'

View File

@@ -1,13 +1,13 @@
GDTEST_OK
~~ WARNING at line 6: (SHADOWED_GLOBAL_IDENTIFIER) The variable "print_debug" has the same name as a built-in function.
~~ WARNING at line 13: (SHADOWED_GLOBAL_IDENTIFIER) The variable "Array" has the same name as a built-in type.
~~ WARNING at line 14: (SHADOWED_GLOBAL_IDENTIFIER) The variable "Node" has the same name as a native class.
~~ WARNING at line 15: (SHADOWED_GLOBAL_IDENTIFIER) The variable "is_same" has the same name as a built-in function.
~~ WARNING at line 16: (SHADOWED_GLOBAL_IDENTIFIER) The variable "sqrt" has the same name as a built-in function.
~~ WARNING at line 17: (SHADOWED_VARIABLE) The local variable "member" is shadowing an already-declared variable at line 4 in the current class.
~~ WARNING at line 18: (SHADOWED_VARIABLE_BASE_CLASS) The local variable "reference" is shadowing an already-declared method in the base class "RefCounted".
~~ WARNING at line 19: (SHADOWED_GLOBAL_IDENTIFIER) The variable "ShadowedClass" has the same name as a global class defined in "shadowning.gd".
~~ WARNING at line 20: (SHADOWED_VARIABLE_BASE_CLASS) The local variable "base_variable_member" is shadowing an already-declared variable at line 4 in the base class "ShadowingBase".
~~ WARNING at line 21: (SHADOWED_VARIABLE_BASE_CLASS) The local constant "base_function_member" is shadowing an already-declared function at line 6 in the base class "ShadowingBase".
~~ WARNING at line 22: (SHADOWED_VARIABLE_BASE_CLASS) The local variable "base_const_member" is shadowing an already-declared constant at line 3 in the base class "ShadowingBase".
~~ WARNING at line 12: (SHADOWED_GLOBAL_IDENTIFIER) The variable "Array" has the same name as a built-in type.
~~ WARNING at line 13: (SHADOWED_GLOBAL_IDENTIFIER) The variable "Node" has the same name as a native class.
~~ WARNING at line 14: (SHADOWED_GLOBAL_IDENTIFIER) The variable "is_same" has the same name as a built-in function.
~~ WARNING at line 15: (SHADOWED_GLOBAL_IDENTIFIER) The variable "sqrt" has the same name as a built-in function.
~~ WARNING at line 16: (SHADOWED_VARIABLE) The local variable "member" is shadowing an already-declared variable at line 4 in the current class.
~~ WARNING at line 17: (SHADOWED_VARIABLE_BASE_CLASS) The local variable "reference" is shadowing an already-declared method in the base class "RefCounted".
~~ WARNING at line 18: (SHADOWED_GLOBAL_IDENTIFIER) The variable "ShadowedClass" has the same name as a global class defined in "shadowning.gd".
~~ WARNING at line 19: (SHADOWED_VARIABLE_BASE_CLASS) The local variable "base_variable_member" is shadowing an already-declared variable at line 4 in the base class "ShadowingBase".
~~ WARNING at line 20: (SHADOWED_VARIABLE_BASE_CLASS) The local constant "base_function_member" is shadowing an already-declared function at line 6 in the base class "ShadowingBase".
~~ WARNING at line 21: (SHADOWED_VARIABLE_BASE_CLASS) The local variable "base_const_member" is shadowing an already-declared constant at line 3 in the base class "ShadowingBase".
warn