Merge commit '1843c454bd' as 'engine'

This commit is contained in:
Sara Gerretsen 2026-04-28 14:58:19 +02:00
commit e7cc4cd72f
13965 changed files with 7502032 additions and 0 deletions

View file

@ -0,0 +1,44 @@
@abstract class AbstractClass:
@abstract func some_func()
class ImplementedClass extends AbstractClass:
func some_func():
pass
@abstract class AbstractClassAgain extends ImplementedClass:
@abstract func some_func()
class Test1:
@abstract func some_func()
class Test2 extends AbstractClass:
pass
class Test3 extends AbstractClassAgain:
pass
class Test4 extends AbstractClass:
func some_func():
super()
func other_func():
super.some_func()
@abstract class A:
@abstract @abstract func abstract_dup()
# An abstract function cannot have a body.
@abstract func abstract_bodyful():
pass
# A static function cannot be marked as `@abstract`.
@abstract static func abstract_stat()
@abstract @abstract class DuplicateAbstract:
pass
func holding_some_invalid_lambda(invalid_default_arg = func():):
var some_invalid_lambda = (func():)
func test():
pass

View file

@ -0,0 +1,13 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 11: Class "Test1" is not abstract but contains abstract methods. Mark the class as "@abstract" or remove "@abstract" from all methods in this class.
>> ERROR at line 14: Class "Test2" must implement "AbstractClass.some_func()" and other inherited abstract methods or be marked as "@abstract".
>> ERROR at line 17: Class "Test3" must implement "AbstractClassAgain.some_func()" and other inherited abstract methods or be marked as "@abstract".
>> ERROR at line 22: Cannot call the parent class' abstract function "some_func()" because it hasn't been defined.
>> ERROR at line 25: Cannot call the parent class' abstract function "some_func()" because it hasn't been defined.
>> ERROR at line 28: "@abstract" annotation can only be used once per function.
>> ERROR at line 32: An abstract function cannot have a body.
>> ERROR at line 35: "@abstract" annotation cannot be applied to static functions.
>> ERROR at line 35: A function must either have a ":" followed by a body, or be marked as "@abstract".
>> ERROR at line 37: "@abstract" annotation can only be used once per class.
>> ERROR at line 40: A lambda function must have a ":" followed by a body.
>> ERROR at line 41: A lambda function must have a ":" followed by a body.

View file

@ -0,0 +1,6 @@
var num := 1
@export_range(num, 10) var a
func test():
pass

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 3: Argument 1 of annotation "@export_range" isn't a constant expression.

View file

@ -0,0 +1,14 @@
enum { VALUE }
enum NamedEnum { VALUE }
const CONST = 0
signal signal_1
signal signal_2
func test():
VALUE = 1
NamedEnum = {}
NamedEnum.VALUE = 1
CONST = 1
signal_1 = signal_2

View file

@ -0,0 +1,6 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 10: Cannot assign a new value to a constant.
>> ERROR at line 11: Cannot assign a new value to a constant.
>> ERROR at line 12: Cannot assign a new value to a constant.
>> ERROR at line 13: Cannot assign a new value to a constant.
>> ERROR at line 14: Cannot assign a new value to a constant.

View file

@ -0,0 +1,10 @@
func test():
# Directly.
var tree := SceneTree.new()
tree.root = Window.new()
tree.free()
# Indirectly.
var state := PhysicsDirectBodyState3DExtension.new()
state.center_of_mass.x += 1.0
state.free()

View file

@ -0,0 +1,3 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 4: Cannot assign a new value to a read-only property.
>> ERROR at line 9: Cannot assign a new value to a read-only property.

View file

@ -0,0 +1,3 @@
func test():
var var_color: String = Color.RED
print('not ok')

View file

@ -0,0 +1,3 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 2: Cannot assign a value of type "Color" as "String".
>> ERROR at line 2: Cannot assign a value of type Color to variable "var_color" with specified type String.

View file

@ -0,0 +1,4 @@
signal my_signal()
func test():
var _a := await my_signal

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 4: Cannot infer the type of "_a" variable because the value doesn't have a set type.

View file

@ -0,0 +1,3 @@
func test():
print(2.2 << 4)
print(2 >> 4.4)

View file

@ -0,0 +1,3 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 2: Invalid operands to operator <<, float and int.
>> ERROR at line 3: Invalid operands to operator >>, int and float.

View file

@ -0,0 +1,7 @@
# GH-73283
class MyClass:
pass
func test():
MyClass.not_existing_method()

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 7: Static function "not_existing_method()" not found in base "MyClass".

View file

@ -0,0 +1,7 @@
const ARRAY: Array = [0]
const DICTIONARY: Dictionary = { 0: 0 }
func test():
var key: int = 0
ARRAY[key] = 0
DICTIONARY[key] = 0

View file

@ -0,0 +1,3 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 6: Cannot assign a new value to a constant.
>> ERROR at line 7: Cannot assign a new value to a constant.

View file

@ -0,0 +1,5 @@
const base := [0]
func test():
var sub := base[0]
if sub is String: pass

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 5: Expression is of type "int" so it can't be of type "String".

View file

@ -0,0 +1,10 @@
extends RefCounted
const AbstractScript = preload("./construct_abstract_script.notest.gd")
@abstract class AbstractClass:
pass
func test():
var _a := AbstractScript.new()
var _b := AbstractClass.new()

View file

@ -0,0 +1,3 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 9: Cannot construct abstract class "AbstractScript".
>> ERROR at line 10: Cannot construct abstract class "AbstractClass".

View file

@ -0,0 +1 @@
@abstract class_name AbstractScript

View file

@ -0,0 +1,10 @@
class A:
func _init():
pass
class B extends A: pass
class C extends A: pass
func test():
var x := B.new()
print(x is C)

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 10: Expression is of type "B" so it can't be of type "C".

View file

@ -0,0 +1,41 @@
enum NamedEnum0 { VALUE = NamedEnum0.VALUE }
enum NamedEnum1 { VALUE = NamedEnum2.VALUE }
enum NamedEnum2 { VALUE = NamedEnum1.VALUE }
enum { ENUM_VALUE_0 = ENUM_VALUE_0 }
enum { ENUM_VALUE_1 = ENUM_VALUE_2 }
enum { ENUM_VALUE_2 = ENUM_VALUE_1 }
const CONST_0 = CONST_0
const CONST_1 = CONST_2
const CONST_2 = CONST_1
var var_0 = var_0
var var_1 := var_2
var var_2 := var_1
static func func_0(p := func_0()) -> int:
return 0
static func func_1(p := func_2()) -> int:
return 1
static func func_2(p := func_1()) -> int:
return 2
var lambda_body = (func (_p): return 0).call(lambda_body_ref)
var lambda_body_ref = lambda_body
var lambda_param = func (_p = lambda_param_ref): return 0
var lambda_param_ref = lambda_param
const External = preload("cyclic_reference.notest.gd")
var member = External.member
class InnerA:
func f(p := InnerB.new().f()) -> int:
return 1
class InnerB extends InnerA:
func f(p := 1) -> int:
return super.f()
func test():
pass

View file

@ -0,0 +1,5 @@
class_name TestCyclicRefExternal
const External = preload("cyclic_reference.gd")
var member = External.member

View file

@ -0,0 +1,27 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 1: Could not resolve member "NamedEnum0": Cyclic reference.
>> ERROR at line 1: Enum values must be constant.
>> ERROR at line 3: Could not resolve member "NamedEnum1": Cyclic reference.
>> ERROR at line 3: Enum values must be constant.
>> ERROR at line 5: Cannot use another enum element before it was declared.
>> ERROR at line 5: Enum values must be constant.
>> ERROR at line 7: Could not resolve member "ENUM_VALUE_1": Cyclic reference.
>> ERROR at line 9: Could not resolve member "CONST_0": Cyclic reference.
>> ERROR at line 9: Could not resolve type for constant "CONST_0".
>> ERROR at line 11: Could not resolve member "CONST_1": Cyclic reference.
>> ERROR at line 11: Could not resolve type for constant "CONST_2".
>> ERROR at line 13: Could not resolve member "var_0": Cyclic reference.
>> ERROR at line 13: Could not resolve type for variable "var_0".
>> ERROR at line 15: Could not resolve member "var_1": Cyclic reference.
>> ERROR at line 15: Cannot infer the type of "var_2" variable because the value doesn't have a set type.
>> ERROR at line 17: Could not resolve member "func_0": Cyclic reference.
>> ERROR at line 17: Cannot infer the type of "p" parameter because the value doesn't have a set type.
>> ERROR at line 21: Could not resolve member "func_1": Cyclic reference.
>> ERROR at line 21: Cannot infer the type of "p" parameter because the value doesn't have a set type.
>> ERROR at line 25: Could not resolve member "lambda_body": Cyclic reference.
>> ERROR at line 25: Could not resolve type for variable "lambda_body_ref".
>> ERROR at line 28: Could not resolve member "lambda_param": Cyclic reference.
>> ERROR at line 28: Could not resolve type for variable "lambda_param_ref".
>> ERROR at line 31: Could not resolve external class member "member".
>> ERROR at line 31: Cannot find member "member" in base "TestCyclicRefExternal".
>> ERROR at line 37: Could not resolve member "f": Cyclic reference.

View file

@ -0,0 +1,16 @@
func test():
var lua_dict = {
a = 1,
b = 2,
a = 3, # Duplicate isn't allowed.
}
var lua_dict_with_string = {
a = 1,
b = 2,
"a" = 3, # Duplicate isn't allowed.
}
var python_dict = {
"a": 1,
"b": 2,
"a": 3, # Duplicate isn't allowed.
}

View file

@ -0,0 +1,4 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 5: Key "a" was already used in this dictionary (at line 3).
>> ERROR at line 10: Key "a" was already used in this dictionary (at line 8).
>> ERROR at line 15: Key "a" was already used in this dictionary (at line 13).

View file

@ -0,0 +1,9 @@
# https://github.com/godotengine/godot/issues/62957
func test():
var dict = {
&"key": "StringName",
"key": "String"
}
print("Invalid dictionary: %s" % dict)

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 6: Key "key" was already used in this dictionary (at line 5).

View file

@ -0,0 +1,28 @@
enum BadEnum {
A = 0.0,
B = "hello",
}
enum CustomEnum { A, B }
func test():
print(Variant.Operator) # Global.
print(Vector3.Axis) # Built-in.
print(Node.ProcessMode) # Native.
print(Side.NOT_EXIST) # Global.
print(Vector3.Axis.NOT_EXIST) # Built-in.
print(TileSet.TileShape.NOT_EXIST) # Native.
print(CustomEnum.NOT_EXIST) # Custom.
print(Side.size()) # Global.
print(Vector3.Axis.size()) # Built-in.
print(TileSet.TileShape.size()) # Native.
Side.clear() # Global.
Vector3.Axis.clear() # Built-in.
TileSet.TileShape.clear() # Native.
CustomEnum.clear() # Custom.
var enum_type = CustomEnum
enum_type.clear()

View file

@ -0,0 +1,30 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 2: Enum values must be integers.
>> ERROR at line 3: Enum values must be integers.
>> ERROR at line 9: Type "Operator" in base "Variant" cannot be used on its own.
>> ERROR at line 10: Type "Axis" in base "Vector3" cannot be used on its own.
>> ERROR at line 11: Type "ProcessMode" in base "Node" cannot be used on its own.
>> ERROR at line 13: Cannot find member "NOT_EXIST" in base "Side".
>> ERROR at line 14: Cannot find member "NOT_EXIST" in base "Vector3.Axis".
>> ERROR at line 15: Cannot find member "NOT_EXIST" in base "TileSet.TileShape".
>> ERROR at line 16: Cannot find member "NOT_EXIST" in base "enum_declaration_and_usage.gd.CustomEnum".
>> ERROR at line 18: Global enum "Side" cannot be used on its own.
>> ERROR at line 18: The native enum "Side" does not behave like Dictionary and does not have methods of its own.
>> ERROR at line 18: Static function "size()" not found in base "Side".
>> ERROR at line 19: Type "Axis" in base "Vector3" cannot be used on its own.
>> ERROR at line 19: Native class Vector3.Axis used in script doesn't exist or isn't exposed.
>> ERROR at line 19: Static function "size()" not found in base "Variant".
>> ERROR at line 20: Type "TileShape" in base "TileSet" cannot be used on its own.
>> ERROR at line 20: Native class TileSet.TileShape used in script doesn't exist or isn't exposed.
>> ERROR at line 20: Static function "size()" not found in base "Variant".
>> ERROR at line 22: Global enum "Side" cannot be used on its own.
>> ERROR at line 22: The native enum "Side" does not behave like Dictionary and does not have methods of its own.
>> ERROR at line 22: Static function "clear()" not found in base "Side".
>> ERROR at line 23: Type "Axis" in base "Vector3" cannot be used on its own.
>> ERROR at line 23: Native class Vector3.Axis used in script doesn't exist or isn't exposed.
>> ERROR at line 23: Static function "clear()" not found in base "Variant".
>> ERROR at line 24: Type "TileShape" in base "TileSet" cannot be used on its own.
>> ERROR at line 24: Native class TileSet.TileShape used in script doesn't exist or isn't exposed.
>> ERROR at line 24: Static function "clear()" not found in base "Variant".
>> ERROR at line 25: Cannot call non-const Dictionary function "clear()" on enum "CustomEnum".
>> ERROR at line 28: Cannot call non-const Dictionary function "clear()" on enum "CustomEnum".

View file

@ -0,0 +1,39 @@
class InnerClass:
enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 }
enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 }
enum MyOtherEnum { OTHER_ENUM_VALUE_1, OTHER_ENUM_VALUE_2 }
enum { ENUM_VALUE_1, ENUM_VALUE_2 }
var class_var_1: MyEnum = MyOtherEnum.OTHER_ENUM_VALUE_1
var class_var_2: MyEnum
func enum_func_1(e: MyEnum) -> void:
print(e)
func enum_func_2() -> MyEnum:
return MyOtherEnum.OTHER_ENUM_VALUE_1
func test():
class_var_2 = MyOtherEnum.OTHER_ENUM_VALUE_2
var local_var_1: MyEnum = MyOtherEnum.OTHER_ENUM_VALUE_1
var local_var_2: MyEnum
local_var_2 = MyOtherEnum.OTHER_ENUM_VALUE_2
var local_var_3: MyEnum
local_var_3 = InnerClass.MyEnum.ENUM_VALUE_2
var local_var_4: MyEnum = ENUM_VALUE_1
const P1 = preload("../features/enum_from_outer.gd")
var local_var_5: MyEnum
local_var_5 = P1.Named.VALUE_A
const P2 = preload("../features/enum_value_from_parent.gd")
var local_var_6: MyEnum
local_var_6 = P2.VALUE_B
enum_func_1(MyOtherEnum.OTHER_ENUM_VALUE_1)

View file

@ -0,0 +1,21 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 9: Cannot assign a value of type "enum_type_checking.gd.MyOtherEnum" as "enum_type_checking.gd.MyEnum".
>> ERROR at line 9: Cannot assign a value of type enum_type_checking.gd.MyOtherEnum to variable "class_var_1" with specified type enum_type_checking.gd.MyEnum.
>> ERROR at line 16: Cannot return a value of type "enum_type_checking.gd.MyOtherEnum" as "enum_type_checking.gd.MyEnum".
>> ERROR at line 16: Cannot return value of type "enum_type_checking.gd.MyOtherEnum" because the function return type is "enum_type_checking.gd.MyEnum".
>> ERROR at line 19: Cannot assign a value of type "enum_type_checking.gd.MyOtherEnum" as "enum_type_checking.gd.MyEnum".
>> ERROR at line 19: Value of type "enum_type_checking.gd.MyOtherEnum" cannot be assigned to a variable of type "enum_type_checking.gd.MyEnum".
>> ERROR at line 21: Cannot assign a value of type "enum_type_checking.gd.MyOtherEnum" as "enum_type_checking.gd.MyEnum".
>> ERROR at line 21: Cannot assign a value of type enum_type_checking.gd.MyOtherEnum to variable "local_var_1" with specified type enum_type_checking.gd.MyEnum.
>> ERROR at line 24: Cannot assign a value of type "enum_type_checking.gd.MyOtherEnum" as "enum_type_checking.gd.MyEnum".
>> ERROR at line 24: Value of type "enum_type_checking.gd.MyOtherEnum" cannot be assigned to a variable of type "enum_type_checking.gd.MyEnum".
>> ERROR at line 27: Cannot assign a value of type "enum_type_checking.gd::InnerClass.MyEnum" as "enum_type_checking.gd.MyEnum".
>> ERROR at line 27: Value of type "enum_type_checking.gd::InnerClass.MyEnum" cannot be assigned to a variable of type "enum_type_checking.gd.MyEnum".
>> ERROR at line 29: Cannot assign a value of type "enum_type_checking.gd.<anonymous enum>" as "enum_type_checking.gd.MyEnum".
>> ERROR at line 29: Cannot assign a value of type enum_type_checking.gd.<anonymous enum> to variable "local_var_4" with specified type enum_type_checking.gd.MyEnum.
>> ERROR at line 33: Cannot assign a value of type "enum_from_outer.gd.Named" as "enum_type_checking.gd.MyEnum".
>> ERROR at line 33: Value of type "enum_from_outer.gd.Named" cannot be assigned to a variable of type "enum_type_checking.gd.MyEnum".
>> ERROR at line 37: Cannot assign a value of type "enum_value_from_parent.gd.<anonymous enum>" as "enum_type_checking.gd.MyEnum".
>> ERROR at line 37: Value of type "enum_value_from_parent.gd.<anonymous enum>" cannot be assigned to a variable of type "enum_type_checking.gd.MyEnum".
>> ERROR at line 39: Cannot pass a value of type "enum_type_checking.gd.MyOtherEnum" as "enum_type_checking.gd.MyEnum".
>> ERROR at line 39: Invalid argument for "enum_func_1()" function: argument 1 should be "enum_type_checking.gd.MyEnum" but is "enum_type_checking.gd.MyOtherEnum".

View file

@ -0,0 +1,10 @@
# GH-82809
extends Node
class MyResource extends Resource:
@export var node: Node
@export var node_array: Array[Node]
func test():
pass

View file

@ -0,0 +1,3 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 6: Node export is only supported in Node-derived classes, but the current class inherits "Resource".
>> ERROR at line 7: Node export is only supported in Node-derived classes, but the current class inherits "Resource".

View file

@ -0,0 +1,59 @@
class Iterator:
func _iter_init(_count):
return true
func _iter_next(_count):
return false
func _iter_get(_count) -> StringName:
return &"custom"
enum { ENUM_VALUE = 1 }
func test():
# Literals.
for x in true:
pass
for x in 1:
if x is String:
pass
# Constants.
const CONSTANT_INT = 1
for x in CONSTANT_INT:
if x is String:
pass
const CONSTANT_FLOAT = 1.0
for x in CONSTANT_FLOAT:
if x is String:
pass
# Hard types.
var hard_int := 1
for x in hard_int:
if x is String:
pass
var hard_float := 1.0
for x in hard_float:
if x is String:
pass
var hard_string := "a"
for x in hard_string:
if x is int:
pass
# Other.
for x in ENUM_VALUE:
if x is String:
pass
var hard_iterator := Iterator.new()
for x in hard_iterator:
if x is int:
pass

View file

@ -0,0 +1,10 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 14: Unable to iterate on value of type "bool".
>> ERROR at line 18: Expression is of type "int" so it can't be of type "String".
>> ERROR at line 25: Expression is of type "int" so it can't be of type "String".
>> ERROR at line 30: Expression is of type "float" so it can't be of type "String".
>> ERROR at line 37: Expression is of type "int" so it can't be of type "String".
>> ERROR at line 42: Expression is of type "float" so it can't be of type "String".
>> ERROR at line 47: Expression is of type "String" so it can't be of type "int".
>> ERROR at line 53: Expression is of type "int" so it can't be of type "String".
>> ERROR at line 58: Expression is of type "StringName" so it can't be of type "int".

View file

@ -0,0 +1,11 @@
func test():
var a: Array[Resource] = []
for node: Node in a:
print(node)
# GH-82021
for x: String in [1, 2, 3]:
print(x)
for key: int in { "a": 1 }:
print(key)

View file

@ -0,0 +1,6 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 3: Unable to iterate on value of type "Array[Resource]" with variable of type "Node".
>> ERROR at line 7: Cannot include a value of type "int" as "String".
>> ERROR at line 7: Cannot have an element of type "int" in an array of type "Array[String]".
>> ERROR at line 10: Cannot include a value of type "String" as "int".
>> ERROR at line 10: Cannot have a key of type "String" in a dictionary of type "Dictionary[int, Variant]".

View file

@ -0,0 +1,34 @@
class A:
func f1(_p1: int) -> int: return 0
func f2(_p1: int) -> int: return 0
func f3(_p1: int = 0) -> int: return 0
func f4(_p1: int) -> int: return 0
func f5() -> int: return 0
func g1(_p: Object): pass
func g2(_p: Variant): pass # No `is_type_compatible()` misuse.
func g3(_p: int): pass # No implicit conversion.
func h1() -> Node: return null
func h2() -> Node: return null # No `is_type_compatible()` misuse.
func h3() -> Node: return null # No `is_type_compatible()` misuse.
func h4() -> float: return 0.0 # No implicit conversion.
class B extends A:
func f1() -> int: return 0
func f2(_p1: int, _p2: int) -> int: return 0
func f3(_p1: int) -> int: return 0
func f4(_p1: Vector2) -> int: return 0
func f5() -> Vector2: return Vector2()
func g1(_p: Node): pass
func g2(_p: Node): pass
func g3(_p: float): pass
func h1() -> Object: return null
func h2() -> Variant: return null
func h3() -> void: return
func h4() -> int: return 0
func test():
pass

View file

@ -0,0 +1,13 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 18: The function signature doesn't match the parent. Parent signature is "f1(int) -> int".
>> ERROR at line 19: The function signature doesn't match the parent. Parent signature is "f2(int) -> int".
>> ERROR at line 20: The function signature doesn't match the parent. Parent signature is "f3(int = <default>) -> int".
>> ERROR at line 21: The function signature doesn't match the parent. Parent signature is "f4(int) -> int".
>> ERROR at line 22: The function signature doesn't match the parent. Parent signature is "f5() -> int".
>> ERROR at line 24: The function signature doesn't match the parent. Parent signature is "g1(Object) -> Variant".
>> ERROR at line 25: The function signature doesn't match the parent. Parent signature is "g2(Variant) -> Variant".
>> ERROR at line 26: The function signature doesn't match the parent. Parent signature is "g3(int) -> Variant".
>> ERROR at line 28: The function signature doesn't match the parent. Parent signature is "h1() -> Node".
>> ERROR at line 29: The function signature doesn't match the parent. Parent signature is "h2() -> Node".
>> ERROR at line 30: The function signature doesn't match the parent. Parent signature is "h3() -> Node".
>> ERROR at line 31: The function signature doesn't match the parent. Parent signature is "h4() -> float".

View file

@ -0,0 +1,11 @@
# GH-75645
class MyNode extends Node:
static func static_func():
var node = $Node
class MyRefCounted extends RefCounted:
func non_static_func():
var node = $Node
func test():
pass

View file

@ -0,0 +1,3 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 4: Cannot use shorthand "get_node()" notation ("$") in a static function.
>> ERROR at line 8: Cannot use shorthand "get_node()" notation ("$") on a class that isn't a node.

View file

@ -0,0 +1,3 @@
func test():
var foo: bool = true
foo += 'bar'

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 3: Invalid operands "bool" and "String" for assignment operator.

View file

@ -0,0 +1,9 @@
var member_untyped = 1
var member_inferred := member_untyped
func check(param_untyped = 1, param_inferred := param_untyped):
pass
func test():
var local_untyped = 1
var local_inferred := local_untyped

View file

@ -0,0 +1,4 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 2: Cannot infer the type of "member_inferred" variable because the value doesn't have a set type.
>> ERROR at line 4: Cannot infer the type of "param_inferred" parameter because the value doesn't have a set type.
>> ERROR at line 9: Cannot infer the type of "local_inferred" variable because the value doesn't have a set type.

View file

@ -0,0 +1,3 @@
func test():
# Error here. Array indices must be integers.
print([0, 1][true])

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 3: Invalid index type "bool" for a base of type "Array".

View file

@ -0,0 +1,6 @@
func test():
var integer := 1
print(integer as Array)
print(integer as Node)
var object := RefCounted.new()
print(object as int)

View file

@ -0,0 +1,4 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 3: Invalid cast. Cannot convert from "int" to "Array".
>> ERROR at line 4: Invalid cast. Cannot convert from "int" to "Node".
>> ERROR at line 6: Invalid cast. Cannot convert from "RefCounted" to "int".

View file

@ -0,0 +1,4 @@
func test():
print(true + true)
print({"hello": "world"} + {"godot": "engine"})
print("hello" + ["world"])

View file

@ -0,0 +1,4 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 2: Invalid operands to operator +, bool and bool.
>> ERROR at line 3: Invalid operands "Dictionary" and "Dictionary" for "+" operator.
>> ERROR at line 4: Invalid operands "String" and "Array" for "+" operator.

View file

@ -0,0 +1,5 @@
func test():
var i = 12
# Constants must be made of a constant, deterministic expression.
# A constant that depends on a variable's value is not a constant expression.
const TEST = 13 + i

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 5: Assigned value for constant "TEST" isn't a constant expression.

View file

@ -0,0 +1,35 @@
class SomeClass:
const CONSTANT = 1
const CONSTANT = 1
var variable = 1
# GH-75870
class Class1 extends CONSTANT:
pass
class Class2 extends variable:
pass
# GH-82081. `Time` is an engine singleton.
class Class3 extends Time:
pass
class Class4 extends RefCounted.Nested:
pass
class Class5 extends SomeClass.UnknownClass:
pass
class Class6 extends SomeClass.CONSTANT:
pass
class ClassA extends ClassB:
pass
class ClassB extends ClassA:
pass
func test():
pass

View file

@ -0,0 +1,8 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 10: Constant "CONSTANT" is not a preloaded script or class.
>> ERROR at line 13: Cannot use variable "variable" in extends chain.
>> ERROR at line 17: Cannot inherit native class "Time" because it is an engine singleton.
>> ERROR at line 20: Cannot get nested types for extension from non-GDScript type "RefCounted".
>> ERROR at line 23: Could not find nested type "UnknownClass".
>> ERROR at line 26: Identifier "CONSTANT" is not a preloaded script or class.
>> ERROR at line 29: Cyclic inheritance.

View file

@ -0,0 +1,11 @@
class A extends InstancePlaceholder:
func _init():
pass
class B extends A:
pass
func test():
Time.new()
InstancePlaceholder.new()
B.new()

View file

@ -0,0 +1,6 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 9: Cannot construct native class "Time" because it is an engine singleton.
>> ERROR at line 10: Native class "InstancePlaceholder" cannot be constructed as it is abstract.
>> ERROR at line 10: Name "new" is a Callable. You can call it with "new.call()" instead.
>> ERROR at line 11: Class "invalid_instantiation.gd::B" cannot be constructed as it is based on abstract native class "InstancePlaceholder".
>> ERROR at line 11: Name "new" is a Callable. You can call it with "new.call()" instead.

View file

@ -0,0 +1,14 @@
# In 3.x there are warnings `CONSTANT_USED_AS_FUNCTION`, `FUNCTION_USED_AS_PROPERTY`, and `PROPERTY_USED_AS_FUNCTION`.
# In 4.x they are deprecated because either an error is produced or a `Callable` is returned.
const CONSTANT = 25
var property = 25
func function():
pass
func test():
function = 25
CONSTANT(123)
property()

View file

@ -0,0 +1,6 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 12: Cannot assign a new value to a constant.
>> ERROR at line 13: Member "CONSTANT" is not a function.
>> ERROR at line 13: Name "CONSTANT" called as a function but is a "int".
>> ERROR at line 14: Member "property" is not a function.
>> ERROR at line 14: Name "property" called as a function but is a "int".

View file

@ -0,0 +1,22 @@
static func _static_init() -> int:
pass
func _init() -> int:
pass
func f() -> void:
return null
func g() -> void:
var a
a = 1
return a
func test():
var lambda_1 := func() -> int:
print("no return")
lambda_1.call()
var lambda_2 := func() -> int:
return "string"
lambda_2.call()

View file

@ -0,0 +1,8 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 1: Static constructor cannot have an explicit return type.
>> ERROR at line 4: Constructor cannot have an explicit return type.
>> ERROR at line 8: A void function cannot return a value.
>> ERROR at line 13: A void function cannot return a value.
>> ERROR at line 16: Not all code paths return a value.
>> ERROR at line 21: Cannot return a value of type "String" as "int".
>> ERROR at line 21: Cannot return value of type "String" because the function return type is "int".

View file

@ -0,0 +1,3 @@
func test():
# Number separators may not be placed at the beginning of a number.
var __ = _123

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 3: Identifier "_123" not declared in the current scope.

View file

@ -0,0 +1,11 @@
enum MyEnum { A }
func test():
var use_before_declared: EnumType
const EnumType = MyEnum
var enum_variable = MyEnum
var use_non_constant: enum_variable
const ENUM_VALUE = MyEnum.A
var use_not_type: ENUM_VALUE

View file

@ -0,0 +1,4 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 4: Local constant "EnumType" is not resolved at this point.
>> ERROR at line 8: Local variable "enum_variable" cannot be used as a type.
>> ERROR at line 11: Local constant "ENUM_VALUE" is not a valid type.

View file

@ -0,0 +1,10 @@
func test():
var dict = { a = 1 }
var a = 1
match 2:
dict["a"]: # TODO: Fix positional information (parser bug).
print("not allowed")
a + 2:
print("not allowed")
_ when b == 0:
print("b does not exist")

View file

@ -0,0 +1,4 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 7: Expression in match pattern must be a constant expression, an identifier, or an attribute access ("A.B").
>> ERROR at line 9: Identifier "b" not declared in the current scope.
>> ERROR at line 12: Expression in match pattern must be a constant expression, an identifier, or an attribute access ("A.B").

View file

@ -0,0 +1,6 @@
func args(a, b):
print(a)
print(b)
func test():
args(1,)

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 6: Too few arguments for "args()" call. Expected at least 2 but received 1.

View file

@ -0,0 +1,2 @@
func test():
TileSet.this_does_not_exist # Does not exist

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 2: Cannot find member "this_does_not_exist" in base "TileSet".

View file

@ -0,0 +1,3 @@
func test():
var foo: Foo
print('not ok')

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 2: Could not find type "Foo" in the current scope.

View file

@ -0,0 +1,4 @@
# GH-73213
func test():
print(Object())

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 4: Invalid constructor "Object()", use "Object.new()" instead.

View file

@ -0,0 +1,6 @@
extends RefCounted
@onready var nope := 0
func test():
print("Cannot use @onready without a Node base")

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 3: "@onready" can only be used in classes that inherit "Node".

View file

@ -0,0 +1,7 @@
extends Node
class Inner extends RefCounted:
@onready var nope = 0
func test():
print("Cannot use @onready without a Node base")

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 4: "@onready" can only be used in classes that inherit "Node".

View file

@ -0,0 +1,12 @@
class A:
class B:
func test():
print(A.B.D)
class C:
class D:
pass
func test():
var inst = A.B.new()
inst.test()

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 4: Cannot find member "D" in base "B".

View file

@ -0,0 +1,6 @@
extends Node
var script: int
func test():
pass

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 3: Member "script" redefined (original in native class 'Node')

View file

@ -0,0 +1,9 @@
# https://github.com/godotengine/godot/issues/56702
func test():
# somewhat obscure feature: referencing parameters in defaults, but only earlier ones!
ref_default("non-optional")
func ref_default(nondefault1, defa=nondefault1, defb=defc, defc=1):
prints(nondefault1, nondefault2, defa, defb, defc)

View file

@ -0,0 +1,3 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 8: Identifier "defc" not declared in the current scope.
>> ERROR at line 9: Identifier "nondefault2" not declared in the current scope.

View file

@ -0,0 +1,6 @@
class InnerClass:
pass
func test():
var x : InnerClass.DoesNotExist
print("FAIL")

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 5: Could not find type "DoesNotExist" under base "InnerClass".

View file

@ -0,0 +1,29 @@
var _prop: int
# Inline setter assigns `String` to `int`.
# Inline getter returns `int` instead of `String`.
var prop_1: String:
set(value):
_prop = value
get:
return _prop
# Setter function has wrong argument type.
# Getter function has wrong return type.
var prop_2: String:
set = set_prop_2, get = get_prop_2
# Inline setter parameter uses property type.
var prop_3 := 0:
set(value):
var x: String = value
prop_3 = value
func set_prop_2(value: int):
_prop = value
func get_prop_2():
return _prop
func test():
pass

View file

@ -0,0 +1,6 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 7: Value of type "String" cannot be assigned to a variable of type "int".
>> ERROR at line 9: Cannot return value of type "int" because the function return type is "String".
>> ERROR at line 13: Function with return type "int" cannot be used as getter for a property of type "String".
>> ERROR at line 13: Function with argument type "int" cannot be used as setter for a property of type "String".
>> ERROR at line 19: Cannot assign a value of type int to variable "x" with specified type String.

View file

@ -0,0 +1,9 @@
# See also `parser-warnings/shadowed-constant.gd`.
const CLASS_CONSTANT = 25
func test():
const LOCAL_CONSTANT = 25
CLASS_CONSTANT = 50
LOCAL_CONSTANT = 50

View file

@ -0,0 +1,3 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 8: Cannot assign a new value to a constant.
>> ERROR at line 9: Cannot assign a new value to a constant.

View file

@ -0,0 +1,13 @@
class A:
enum { V }
class B extends A:
enum { V }
class Vector2: pass
enum Vector2i { A, B }
const Vector3 = 0
var Vector3i
func test():
pass

View file

@ -0,0 +1,6 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 5: The member "V" already exists in parent class A.
>> ERROR at line 7: Class "Vector2" hides a built-in type.
>> ERROR at line 8: The member "Vector2i" cannot have the same name as a builtin type.
>> ERROR at line 9: The member "Vector3" cannot have the same name as a builtin type.
>> ERROR at line 10: The member "Vector3i" cannot have the same name as a builtin type.

View file

@ -0,0 +1,78 @@
# GH-83468, GH-91403
func non_static_func():
pass
static var static_var_11 = non_static_func()
static var static_var_12:
set(_value):
var f := func ():
var g := func ():
print(non_static_func())
g.call()
f.call()
static var static_var_13 = func ():
var f := func ():
var g := func ():
print(non_static_func())
g.call()
f.call()
static var static_var_21a = non_static_func
static var static_var_21b = Callable(non_static_func)
static var static_var_22:
set(_value):
var f := func ():
var g := func ():
print(non_static_func)
g.call()
f.call()
static var static_var_23 = func ():
var f := func ():
var g := func ():
print(non_static_func)
g.call()
f.call()
static func static_func_11():
non_static_func()
static func static_func_12():
print(non_static_func)
static func static_func_21():
var f := func ():
var g := func ():
non_static_func()
g.call()
f.call()
static func static_func_22():
var f := func ():
var g := func ():
print(non_static_func)
g.call()
f.call()
static func static_func_31(
f := func ():
var g := func ():
non_static_func()
g.call()
):
f.call()
static func static_func_32(
f := func ():
var g := func ():
print(non_static_func)
g.call()
):
f.call()
func test():
pass

View file

@ -0,0 +1,14 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 6: Cannot call non-static function "non_static_func()" from a static variable initializer.
>> ERROR at line 12: Cannot call non-static function "non_static_func()" from the static function "@static_var_12_setter()".
>> ERROR at line 19: Cannot call non-static function "non_static_func()" from a static variable initializer.
>> ERROR at line 23: Cannot access non-static function "non_static_func" from a static variable initializer.
>> ERROR at line 24: Cannot access non-static function "non_static_func" from a static variable initializer.
>> ERROR at line 30: Cannot access non-static function "non_static_func" from the static function "@static_var_22_setter()".
>> ERROR at line 37: Cannot access non-static function "non_static_func" from a static variable initializer.
>> ERROR at line 42: Cannot call non-static function "non_static_func()" from the static function "static_func_11()".
>> ERROR at line 45: Cannot access non-static function "non_static_func" from the static function "static_func_12()".
>> ERROR at line 50: Cannot call non-static function "non_static_func()" from the static function "static_func_21()".
>> ERROR at line 57: Cannot access non-static function "non_static_func" from the static function "static_func_22()".
>> ERROR at line 64: Cannot call non-static function "non_static_func()" from the static function "static_func_31()".
>> ERROR at line 72: Cannot access non-static function "non_static_func" from the static function "static_func_32()".

Some files were not shown because too many files have changed in this diff Show more