initial commit, 4.5 stable
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled

This commit is contained in:
2025-09-16 20:46:46 -04:00
commit 9d30169a8d
13378 changed files with 7050105 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 }
enum MyOtherEnum { OTHER_ENUM_VALUE_1, OTHER_ENUM_VALUE_2, OTHER_ENUM_VALUE_3 }
func test():
print(MyOtherEnum.OTHER_ENUM_VALUE_3 as MyEnum)

View File

@@ -0,0 +1,3 @@
GDTEST_OK
~~ WARNING at line 5: (INT_AS_ENUM_WITHOUT_MATCH) Cannot cast 2 as Enum "cast_enum_bad_enum.gd.MyEnum": no enum member has matching value.
2

View File

@@ -0,0 +1,4 @@
enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 }
func test():
print(2 as MyEnum)

View File

@@ -0,0 +1,3 @@
GDTEST_OK
~~ WARNING at line 4: (INT_AS_ENUM_WITHOUT_MATCH) Cannot cast 2 as Enum "cast_enum_bad_int.gd.MyEnum": no enum member has matching value.
2

View File

@@ -0,0 +1,23 @@
var member := 1
func test():
var number := 1
var string := "1"
var vector := Vector2i(1, 0)
var array_assign := [1]
var array_index := [1]
var dictionary := { x = 0 }
var lambda := func ():
member = 2 # Member variable, not captured.
number = 2 # Local variable, captured.
string += "2" # Test compound assignment operator.
vector.x = 2 # Test subscript assignment.
array_assign = [2] # Pass-by-reference type, reassignment.
array_index[0] = 2 # Pass-by-reference type, index access.
dictionary.x = 2 # Pass-by-reference type, attribute access.
prints("lambda", member, number, string, vector, array_assign, array_index, dictionary)
lambda.call()
prints("outer", member, number, string, vector, array_assign, array_index, dictionary)

View File

@@ -0,0 +1,7 @@
GDTEST_OK
~~ WARNING at line 13: (CONFUSABLE_CAPTURE_REASSIGNMENT) Reassigning lambda capture does not modify the outer local variable "number".
~~ WARNING at line 14: (CONFUSABLE_CAPTURE_REASSIGNMENT) Reassigning lambda capture does not modify the outer local variable "string".
~~ WARNING at line 15: (CONFUSABLE_CAPTURE_REASSIGNMENT) Reassigning lambda capture does not modify the outer local variable "vector".
~~ WARNING at line 16: (CONFUSABLE_CAPTURE_REASSIGNMENT) Reassigning lambda capture does not modify the outer local variable "array_assign".
lambda 2 2 12 (2, 0) [2] [2] { &"x": 2 }
outer 2 1 1 (1, 0) [1] [2] { &"x": 2 }

View File

@@ -0,0 +1,6 @@
func test():
if true:
var a = 1
print(a)
var a = 2
print(a)

View File

@@ -0,0 +1,4 @@
GDTEST_OK
~~ WARNING at line 3: (CONFUSABLE_LOCAL_DECLARATION) The variable "a" is declared below in the parent block.
1
2

View File

@@ -0,0 +1,6 @@
var a = 1
func test():
print(a)
var a = 2
print(a)

View File

@@ -0,0 +1,5 @@
GDTEST_OK
~~ WARNING at line 4: (CONFUSABLE_LOCAL_USAGE) The identifier "a" will be shadowed below in the block.
~~ WARNING at line 5: (SHADOWED_VARIABLE) The local variable "a" is shadowing an already-declared variable at line 1 in the current class.
1
2

View File

@@ -0,0 +1,6 @@
var a = 1
func test():
print(a)
var a = a + 1
print(a)

View File

@@ -0,0 +1,6 @@
GDTEST_OK
~~ WARNING at line 4: (CONFUSABLE_LOCAL_USAGE) The identifier "a" will be shadowed below in the block.
~~ WARNING at line 5: (CONFUSABLE_LOCAL_USAGE) The identifier "a" will be shadowed below in the block.
~~ WARNING at line 5: (SHADOWED_VARIABLE) The local variable "a" is shadowing an already-declared variable at line 1 in the current class.
1
2

View File

@@ -0,0 +1,7 @@
var a = 1
func test():
for _i in 3:
print(a)
var a = 2
print(a)

View File

@@ -0,0 +1,9 @@
GDTEST_OK
~~ WARNING at line 5: (CONFUSABLE_LOCAL_USAGE) The identifier "a" will be shadowed below in the block.
~~ WARNING at line 6: (SHADOWED_VARIABLE) The local variable "a" is shadowing an already-declared variable at line 1 in the current class.
1
2
1
2
1
2

View File

@@ -0,0 +1,23 @@
enum HasZero { A = 0, B = 1 }
enum HasNoZero { A = 1, B = 2 }
var has_zero: HasZero # No warning, because the default `0` is valid.
var has_no_zero: HasNoZero # Warning, because there is no `0` in the enum.
func test():
print(has_zero)
print(has_no_zero)
# GH-94634. A parameter is either mandatory or has a default value.
func test_no_exec(param: HasNoZero) -> void:
print(param)
# Loop iterator always has a value.
for i: HasNoZero in HasNoZero.values():
print(i)
match param:
# Pattern bind always has a value.
var x:
print(x)

View File

@@ -0,0 +1,4 @@
GDTEST_OK
~~ WARNING at line 4: (ENUM_VARIABLE_WITHOUT_DEFAULT) The variable "has_no_zero" has an enum type and does not set an explicit default value. The default will be set to "0".
0
0

View File

@@ -0,0 +1,30 @@
extends Node
var add_node = do_add_nodes() # Hack to have nodes on init and not fail at runtime.
var shorthand = $Node
var with_self = self.get_node(^"Node")
var without_self = get_node(^"Node")
var with_cast = get_node(^"Node") as Node
var shorthand_with_cast = $Node as Node
var shorthand_unique = %UniqueNode
var shorthand_in_dollar_unique = $"%UniqueNode"
var without_self_unique = get_node(^"%UniqueNode")
var shorthand_with_cast_unique = %UniqueNode as Node
func test():
print("warn")
func do_add_nodes():
var node = Node.new()
node.name = "Node"
@warning_ignore("unsafe_call_argument")
add_child(node)
var unique_node = Node.new()
unique_node.name = "UniqueNode"
@warning_ignore("unsafe_call_argument")
add_child(unique_node)
unique_node.owner = self
unique_node.unique_name_in_owner = true

View File

@@ -0,0 +1,11 @@
GDTEST_OK
~~ WARNING at line 5: (GET_NODE_DEFAULT_WITHOUT_ONREADY) The default value uses "$" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this.
~~ WARNING at line 6: (GET_NODE_DEFAULT_WITHOUT_ONREADY) The default value uses "get_node()" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this.
~~ WARNING at line 7: (GET_NODE_DEFAULT_WITHOUT_ONREADY) The default value uses "get_node()" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this.
~~ WARNING at line 8: (GET_NODE_DEFAULT_WITHOUT_ONREADY) The default value uses "get_node()" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this.
~~ WARNING at line 9: (GET_NODE_DEFAULT_WITHOUT_ONREADY) The default value uses "$" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this.
~~ WARNING at line 11: (GET_NODE_DEFAULT_WITHOUT_ONREADY) The default value uses "%" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this.
~~ WARNING at line 12: (GET_NODE_DEFAULT_WITHOUT_ONREADY) The default value uses "$" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this.
~~ WARNING at line 13: (GET_NODE_DEFAULT_WITHOUT_ONREADY) The default value uses "get_node()" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this.
~~ WARNING at line 14: (GET_NODE_DEFAULT_WITHOUT_ONREADY) The default value uses "%" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this.
warn

View File

@@ -0,0 +1,6 @@
func test():
var inferred_with_variant := return_variant()
print(inferred_with_variant)
func return_variant() -> Variant:
return "warn"

View File

@@ -0,0 +1,3 @@
GDTEST_OK
~~ WARNING at line 2: (INFERENCE_ON_VARIANT) The variable type is being inferred from a Variant value, so it will be typed as Variant.
warn

View File

@@ -0,0 +1,6 @@
var shadow: int
func test():
var lambda := func(shadow: String) -> void:
print(shadow)
lambda.call('shadow')

View File

@@ -0,0 +1,3 @@
GDTEST_OK
~~ WARNING at line 4: (SHADOWED_VARIABLE) The local function parameter "shadow" is shadowing an already-declared variable at line 1 in the current class.
shadow

View File

@@ -0,0 +1,4 @@
func test():
var lambda := func(unused: Variant) -> void:
pass
lambda.call("something")

View File

@@ -0,0 +1,2 @@
GDTEST_OK
~~ WARNING at line 2: (UNUSED_PARAMETER) The parameter "unused" is never used in the function "<anonymous lambda>()". If this is intended, prefix it with an underscore: "_unused".

View File

@@ -0,0 +1,7 @@
extends "./non_tool_extends_tool.notest.gd"
class InnerClass extends "./non_tool_extends_tool.notest.gd":
pass
func test():
pass

View File

@@ -0,0 +1,3 @@
GDTEST_OK
~~ WARNING at line 1: (MISSING_TOOL) The base class script has the "@tool" annotation, but this script does not have it.
~~ WARNING at line 3: (MISSING_TOOL) The base class script has the "@tool" annotation, but this script does not have it.

View File

@@ -0,0 +1,9 @@
@warning_ignore("missing_tool")
extends "./non_tool_extends_tool.notest.gd"
@warning_ignore("missing_tool")
class InnerClass extends "./non_tool_extends_tool.notest.gd":
pass
func test():
pass

View File

@@ -0,0 +1,6 @@
extends Node
@onready @export var conflict = ""
func test():
print("warn")

View File

@@ -0,0 +1,3 @@
GDTEST_OK
~~ WARNING at line 3: (ONREADY_WITH_EXPORT) "@onready" will set the default value after "@export" takes effect and will override it.
warn

View File

@@ -0,0 +1,5 @@
func test():
print("warn")
func get(_property: StringName) -> Variant:
return null

View File

@@ -0,0 +1,3 @@
GDTEST_OK
~~ WARNING at line 4: (NATIVE_METHOD_OVERRIDE) The method "get()" overrides a method from native class "Object". This won't be called by the engine and may not work as expected.
warn

View File

@@ -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()

View File

@@ -0,0 +1,10 @@
GDTEST_OK
~~ WARNING at line 26: (REDUNDANT_AWAIT) "await" keyword is unnecessary because the expression isn't a coroutine nor a signal.
~~ WARNING at line 28: (REDUNDANT_AWAIT) "await" keyword is unnecessary because the expression isn't a coroutine nor a signal.
~~ WARNING at line 32: (REDUNDANT_AWAIT) "await" keyword is unnecessary because the expression isn't a coroutine nor a signal.
~~ WARNING at line 38: (REDUNDANT_AWAIT) "await" keyword is unnecessary because the expression isn't a coroutine nor a signal.
~~ WARNING at line 44: (REDUNDANT_AWAIT) "await" keyword is unnecessary because the expression isn't a coroutine nor a signal.
~~ WARNING at line 45: (REDUNDANT_AWAIT) "await" keyword is unnecessary because the expression isn't a coroutine nor a signal.
~~ WARNING at line 46: (REDUNDANT_AWAIT) "await" keyword is unnecessary because the expression isn't a coroutine nor a signal.
~~ WARNING at line 51: (REDUNDANT_AWAIT) "await" keyword is unnecessary because the expression isn't a coroutine nor a signal.
~~ WARNING at line 53: (REDUNDANT_AWAIT) "await" keyword is unnecessary because the expression isn't a coroutine nor a signal.

View File

@@ -0,0 +1,7 @@
class_name ShadowingBase
const base_const_member = 1
var base_variable_member
func base_function_member():
pass

View File

@@ -0,0 +1,23 @@
class_name ShadowedClass
extends ShadowingBase
var member: int = 0
var print_debug := 'print_debug'
@warning_ignore('shadowed_global_identifier')
var print := 'print'
@warning_ignore_start('unused_variable', 'unused_local_constant')
func test():
var Array := 'Array'
var Node := 'Node'
var is_same := 'is_same'
var sqrt := 'sqrt'
var member := 'member'
var reference := 'reference'
var ShadowedClass := 'ShadowedClass'
var base_variable_member
const base_function_member = 1
var base_const_member
print('warn')

View File

@@ -0,0 +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 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

View File

@@ -0,0 +1,54 @@
func variant_func(x: Variant) -> void:
print(x)
func int_func(x: int) -> void:
print(x)
func float_func(x: float) -> void:
print(x)
func node_func(x: Node) -> void:
print(x)
# We don't want to execute it because of errors, just analyze.
func no_exec_test():
var variant: Variant = null
var untyped_int = 42
var untyped_string = "abc"
var variant_int: Variant = 42
var variant_string: Variant = "abc"
var typed_int: int = 42
variant_func(untyped_int) # No warning.
variant_func(untyped_string) # No warning.
variant_func(variant_int) # No warning.
variant_func(variant_string) # No warning.
variant_func(typed_int) # No warning.
int_func(untyped_int)
int_func(untyped_string)
int_func(variant_int)
int_func(variant_string)
int_func(typed_int) # No warning.
float_func(untyped_int)
float_func(untyped_string)
float_func(variant_int)
float_func(variant_string)
float_func(typed_int) # No warning.
node_func(variant)
node_func(Object.new())
node_func(Node.new()) # No warning.
node_func(Node2D.new()) # No warning.
# GH-82529
print(Callable(self, "test")) # No warning.
print(Callable(variant, "test"))
print(Dictionary(variant))
print(Vector2(variant))
print(int(variant))
func test():
pass

View File

@@ -0,0 +1,15 @@
GDTEST_OK
~~ WARNING at line 28: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "int_func()" requires the subtype "int" but the supertype "Variant" was provided.
~~ WARNING at line 29: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "int_func()" requires the subtype "int" but the supertype "Variant" was provided.
~~ WARNING at line 30: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "int_func()" requires the subtype "int" but the supertype "Variant" was provided.
~~ WARNING at line 31: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "int_func()" requires the subtype "int" but the supertype "Variant" was provided.
~~ WARNING at line 34: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "float_func()" requires the subtype "float" but the supertype "Variant" was provided.
~~ WARNING at line 35: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "float_func()" requires the subtype "float" but the supertype "Variant" was provided.
~~ WARNING at line 36: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "float_func()" requires the subtype "float" but the supertype "Variant" was provided.
~~ WARNING at line 37: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "float_func()" requires the subtype "float" but the supertype "Variant" was provided.
~~ WARNING at line 40: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "node_func()" requires the subtype "Node" but the supertype "Variant" was provided.
~~ WARNING at line 41: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "node_func()" requires the subtype "Node" but the supertype "Object" was provided.
~~ WARNING at line 47: (UNSAFE_CALL_ARGUMENT) The argument 1 of the constructor "Callable()" requires the subtype "Object" but the supertype "Variant" was provided.
~~ WARNING at line 49: (UNSAFE_CALL_ARGUMENT) The argument 1 of the constructor "Dictionary()" requires the subtype "Dictionary" but the supertype "Variant" was provided.
~~ WARNING at line 50: (UNSAFE_CALL_ARGUMENT) The argument 1 of the constructor "Vector2()" requires the subtype "Vector2" or "Vector2i" but the supertype "Variant" was provided.
~~ WARNING at line 51: (UNSAFE_CALL_ARGUMENT) The argument 1 of the constructor "int()" requires the subtype "int", "bool", or "float" but the supertype "Variant" was provided.

View File

@@ -0,0 +1,24 @@
# We don't want to execute it because of errors, just analyze.
func no_exec_test():
var weak_int = 1
print(weak_int as Variant) # No warning.
print(weak_int as int)
print(weak_int as Node)
var weak_node = Node.new()
print(weak_node as Variant) # No warning.
print(weak_node as int)
print(weak_node as Node)
var weak_variant = null
print(weak_variant as Variant) # No warning.
print(weak_variant as int)
print(weak_variant as Node)
var hard_variant: Variant = null
print(hard_variant as Variant) # No warning.
print(hard_variant as int)
print(hard_variant as Node)
func test():
pass

View File

@@ -0,0 +1,9 @@
GDTEST_OK
~~ WARNING at line 5: (UNSAFE_CAST) Casting "Variant" to "int" is unsafe.
~~ WARNING at line 6: (UNSAFE_CAST) Casting "Variant" to "Node" is unsafe.
~~ WARNING at line 10: (UNSAFE_CAST) Casting "Variant" to "int" is unsafe.
~~ WARNING at line 11: (UNSAFE_CAST) Casting "Variant" to "Node" is unsafe.
~~ WARNING at line 15: (UNSAFE_CAST) Casting "Variant" to "int" is unsafe.
~~ WARNING at line 16: (UNSAFE_CAST) Casting "Variant" to "Node" is unsafe.
~~ WARNING at line 20: (UNSAFE_CAST) Casting "Variant" to "int" is unsafe.
~~ WARNING at line 21: (UNSAFE_CAST) Casting "Variant" to "Node" is unsafe.

View File

@@ -0,0 +1,10 @@
# GH-72135
var _a
@warning_ignore("unused_private_class_variable")
var _b
@warning_ignore("unused_private_class_variable") var _c
var _d
func test():
pass

View File

@@ -0,0 +1,3 @@
GDTEST_OK
~~ WARNING at line 3: (UNUSED_PRIVATE_CLASS_VARIABLE) The class variable "_a" is declared but never used in the class.
~~ WARNING at line 7: (UNUSED_PRIVATE_CLASS_VARIABLE) The class variable "_d" is declared but never used in the class.

View File

@@ -0,0 +1,29 @@
# Doesn't produce the warning:
signal used_as_first_class_signal()
signal used_with_signal_constructor()
signal used_with_signal_emit()
signal used_with_object_emit_signal()
signal used_with_object_connect()
signal used_with_object_disconnect()
signal used_with_self_prefix()
# Produce the warning:
signal used_with_dynamic_name()
signal just_unused()
@warning_ignore("unused_signal")
signal unused_but_ignored()
func no_exec():
print(used_as_first_class_signal)
print(Signal(self, "used_with_signal_constructor"))
used_with_signal_emit.emit()
print(emit_signal("used_with_object_emit_signal"))
print(connect("used_with_object_connect", Callable()))
disconnect("used_with_object_disconnect", Callable())
print(self.emit_signal("used_with_self_prefix"))
var dynamic_name := "used_with_dynamic_name"
print(emit_signal(dynamic_name))
func test():
pass

View File

@@ -0,0 +1,3 @@
GDTEST_OK
~~ WARNING at line 11: (UNUSED_SIGNAL) The signal "used_with_dynamic_name" is declared but never explicitly used in the class.
~~ WARNING at line 12: (UNUSED_SIGNAL) The signal "just_unused" is declared but never explicitly used in the class.