summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/tests/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/tests/scripts')
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/call_not_existing_static_method.gd7
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/call_not_existing_static_method.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_array.gd5
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_array.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_1.gd10
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_1.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_2.gd10
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_2.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_3.gd10
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_3.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_1.gd10
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_1.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_2.gd10
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_2.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_3.gd10
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_3.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_4.gd10
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_4.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/match_guard_invalid_expression.gd4
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/match_guard_invalid_expression.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/object_invalid_constructor.gd4
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/object_invalid_constructor.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/function_param_type_contravariance.gd20
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/function_param_type_contravariance.out1
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/function_return_type_covariance.gd32
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/function_return_type_covariance.out1
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/hard_variants.gd1
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/null_initializer.gd4
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.gd1
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/unsafe_call_argument.gd37
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/unsafe_call_argument.out33
-rw-r--r--modules/gdscript/tests/scripts/parser/errors/match_guard_with_assignment.gd5
-rw-r--r--modules/gdscript/tests/scripts/parser/errors/match_guard_with_assignment.out2
-rw-r--r--modules/gdscript/tests/scripts/parser/features/allowed_keywords_as_identifiers.gd4
-rw-r--r--modules/gdscript/tests/scripts/parser/features/allowed_keywords_as_identifiers.out1
-rw-r--r--modules/gdscript/tests/scripts/parser/features/dollar_and_percent_get_node.gd5
-rw-r--r--modules/gdscript/tests/scripts/parser/features/dollar_node_paths.gd2
-rw-r--r--modules/gdscript/tests/scripts/parser/features/lambda_ends_with_new_line.gd1
-rw-r--r--modules/gdscript/tests/scripts/parser/features/nested_function_calls.gd1
-rw-r--r--modules/gdscript/tests/scripts/parser/features/super.gd1
-rw-r--r--modules/gdscript/tests/scripts/parser/features/unicode_identifiers.gd1
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/for_loop_iterator_specified_types.gd6
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/for_loop_iterator_specified_types.out4
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/match_with_pattern_guards.gd71
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/match_with_pattern_guards.out10
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/member_info_inheritance.gd45
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/member_info_inheritance.out24
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/object_constructor.gd6
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/object_constructor.out2
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/standalone-calls-do-not-write-to-nil.gd1
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/static_variables.gd1
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/stringify.gd3
-rw-r--r--modules/gdscript/tests/scripts/utils.notest.gd84
53 files changed, 438 insertions, 84 deletions
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/call_not_existing_static_method.gd b/modules/gdscript/tests/scripts/analyzer/errors/call_not_existing_static_method.gd
new file mode 100644
index 0000000000..87d1b9ea18
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/call_not_existing_static_method.gd
@@ -0,0 +1,7 @@
+# GH-73283
+
+class MyClass:
+ pass
+
+func test():
+ MyClass.not_existing_method()
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/call_not_existing_static_method.out b/modules/gdscript/tests/scripts/analyzer/errors/call_not_existing_static_method.out
new file mode 100644
index 0000000000..7340058dd4
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/call_not_existing_static_method.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Static function "not_existing_method()" not found in base "MyClass".
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_array.gd b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_array.gd
new file mode 100644
index 0000000000..db3f3f4c72
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_array.gd
@@ -0,0 +1,5 @@
+# GH-82021
+
+func test():
+ for x: String in [1, 2, 3]:
+ print(x)
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_array.out b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_array.out
new file mode 100644
index 0000000000..0bb654e7e2
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_array.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Cannot include a value of type "int" as "String".
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_1.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_1.gd
new file mode 100644
index 0000000000..fdf22f6843
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_1.gd
@@ -0,0 +1,10 @@
+class A:
+ func f(_p: Object):
+ pass
+
+class B extends A:
+ func f(_p: Node):
+ pass
+
+func test():
+ pass
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_1.out b/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_1.out
new file mode 100644
index 0000000000..c6a7e40e8c
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_1.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+The function signature doesn't match the parent. Parent signature is "f(Object) -> Variant".
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_2.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_2.gd
new file mode 100644
index 0000000000..e4094f1d76
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_2.gd
@@ -0,0 +1,10 @@
+class A:
+ func f(_p: Variant):
+ pass
+
+class B extends A:
+ func f(_p: Node): # No `is_type_compatible()` misuse.
+ pass
+
+func test():
+ pass
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_2.out b/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_2.out
new file mode 100644
index 0000000000..52a6efc6fc
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_2.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+The function signature doesn't match the parent. Parent signature is "f(Variant) -> Variant".
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_3.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_3.gd
new file mode 100644
index 0000000000..17663da4f6
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_3.gd
@@ -0,0 +1,10 @@
+class A:
+ func f(_p: int):
+ pass
+
+class B extends A:
+ func f(_p: float): # No implicit conversion.
+ pass
+
+func test():
+ pass
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_3.out b/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_3.out
new file mode 100644
index 0000000000..7a6207fd45
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_3.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+The function signature doesn't match the parent. Parent signature is "f(int) -> Variant".
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_1.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_1.gd
new file mode 100644
index 0000000000..6dfa75ecbc
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_1.gd
@@ -0,0 +1,10 @@
+class A:
+ func f() -> Node:
+ return null
+
+class B extends A:
+ func f() -> Object:
+ return null
+
+func test():
+ pass
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_1.out b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_1.out
new file mode 100644
index 0000000000..e680b2bd77
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_1.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+The function signature doesn't match the parent. Parent signature is "f() -> Node".
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_2.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_2.gd
new file mode 100644
index 0000000000..366494b94f
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_2.gd
@@ -0,0 +1,10 @@
+class A:
+ func f() -> Node:
+ return null
+
+class B extends A:
+ func f() -> Variant: # No `is_type_compatible()` misuse.
+ return null
+
+func test():
+ pass
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_2.out b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_2.out
new file mode 100644
index 0000000000..e680b2bd77
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_2.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+The function signature doesn't match the parent. Parent signature is "f() -> Node".
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_3.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_3.gd
new file mode 100644
index 0000000000..2cb4e7c616
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_3.gd
@@ -0,0 +1,10 @@
+class A:
+ func f() -> Node:
+ return null
+
+class B extends A:
+ func f() -> void: # No `is_type_compatible()` misuse.
+ return
+
+func test():
+ pass
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_3.out b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_3.out
new file mode 100644
index 0000000000..e680b2bd77
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_3.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+The function signature doesn't match the parent. Parent signature is "f() -> Node".
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_4.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_4.gd
new file mode 100644
index 0000000000..2cabce46f5
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_4.gd
@@ -0,0 +1,10 @@
+class A:
+ func f() -> float:
+ return 0.0
+
+class B extends A:
+ func f() -> int: # No implicit conversion.
+ return 0
+
+func test():
+ pass
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_4.out b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_4.out
new file mode 100644
index 0000000000..72f2c493d4
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_4.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+The function signature doesn't match the parent. Parent signature is "f() -> float".
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/match_guard_invalid_expression.gd b/modules/gdscript/tests/scripts/analyzer/errors/match_guard_invalid_expression.gd
new file mode 100644
index 0000000000..1dcb9fc36a
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/match_guard_invalid_expression.gd
@@ -0,0 +1,4 @@
+func test():
+ match 0:
+ _ when a == 0:
+ print("a does not exist")
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/match_guard_invalid_expression.out b/modules/gdscript/tests/scripts/analyzer/errors/match_guard_invalid_expression.out
new file mode 100644
index 0000000000..c5f0a90d6a
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/match_guard_invalid_expression.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Identifier "a" not declared in the current scope.
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/object_invalid_constructor.gd b/modules/gdscript/tests/scripts/analyzer/errors/object_invalid_constructor.gd
new file mode 100644
index 0000000000..1600c3001f
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/object_invalid_constructor.gd
@@ -0,0 +1,4 @@
+# GH-73213
+
+func test():
+ print(Object())
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/object_invalid_constructor.out b/modules/gdscript/tests/scripts/analyzer/errors/object_invalid_constructor.out
new file mode 100644
index 0000000000..27668fcd48
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/object_invalid_constructor.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Invalid constructor "Object()", use "Object.new()" instead.
diff --git a/modules/gdscript/tests/scripts/analyzer/features/function_param_type_contravariance.gd b/modules/gdscript/tests/scripts/analyzer/features/function_param_type_contravariance.gd
new file mode 100644
index 0000000000..a43c233625
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/function_param_type_contravariance.gd
@@ -0,0 +1,20 @@
+class A:
+ func int_to_variant(_p: int): pass
+ func node_to_variant(_p: Node): pass
+ func node_2d_to_node(_p: Node2D): pass
+
+ func variant_to_untyped(_p: Variant): pass
+ func int_to_untyped(_p: int): pass
+ func node_to_untyped(_p: Node): pass
+
+class B extends A:
+ func int_to_variant(_p: Variant): pass
+ func node_to_variant(_p: Variant): pass
+ func node_2d_to_node(_p: Node): pass
+
+ func variant_to_untyped(_p): pass
+ func int_to_untyped(_p): pass
+ func node_to_untyped(_p): pass
+
+func test():
+ pass
diff --git a/modules/gdscript/tests/scripts/analyzer/features/function_param_type_contravariance.out b/modules/gdscript/tests/scripts/analyzer/features/function_param_type_contravariance.out
new file mode 100644
index 0000000000..d73c5eb7cd
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/function_param_type_contravariance.out
@@ -0,0 +1 @@
+GDTEST_OK
diff --git a/modules/gdscript/tests/scripts/analyzer/features/function_return_type_covariance.gd b/modules/gdscript/tests/scripts/analyzer/features/function_return_type_covariance.gd
new file mode 100644
index 0000000000..4de50b6731
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/function_return_type_covariance.gd
@@ -0,0 +1,32 @@
+class A:
+ func variant_to_int() -> Variant: return 0
+ func variant_to_node() -> Variant: return null
+ func node_to_node_2d() -> Node: return null
+
+ func untyped_to_void(): pass
+ func untyped_to_variant(): pass
+ func untyped_to_int(): pass
+ func untyped_to_node(): pass
+
+ func void_to_untyped() -> void: pass
+ func variant_to_untyped() -> Variant: return null
+ func int_to_untyped() -> int: return 0
+ func node_to_untyped() -> Node: return null
+
+class B extends A:
+ func variant_to_int() -> int: return 0
+ func variant_to_node() -> Node: return null
+ func node_to_node_2d() -> Node2D: return null
+
+ func untyped_to_void() -> void: pass
+ func untyped_to_variant() -> Variant: return null
+ func untyped_to_int() -> int: return 0
+ func untyped_to_node() -> Node: return null
+
+ func void_to_untyped(): pass
+ func variant_to_untyped(): pass
+ func int_to_untyped(): pass
+ func node_to_untyped(): pass
+
+func test():
+ pass
diff --git a/modules/gdscript/tests/scripts/analyzer/features/function_return_type_covariance.out b/modules/gdscript/tests/scripts/analyzer/features/function_return_type_covariance.out
new file mode 100644
index 0000000000..d73c5eb7cd
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/function_return_type_covariance.out
@@ -0,0 +1 @@
+GDTEST_OK
diff --git a/modules/gdscript/tests/scripts/analyzer/features/hard_variants.gd b/modules/gdscript/tests/scripts/analyzer/features/hard_variants.gd
index b447180ea8..d0f895d784 100644
--- a/modules/gdscript/tests/scripts/analyzer/features/hard_variants.gd
+++ b/modules/gdscript/tests/scripts/analyzer/features/hard_variants.gd
@@ -23,6 +23,7 @@ func test() -> void:
typed = variant()
inferred = variant()
+ @warning_ignore("unsafe_call_argument") # TODO: Hard vs Weak vs Unknown.
param_weak(typed)
param_typed(typed)
param_inferred(typed)
diff --git a/modules/gdscript/tests/scripts/analyzer/features/null_initializer.gd b/modules/gdscript/tests/scripts/analyzer/features/null_initializer.gd
index 5a413e2015..08e7dc590e 100644
--- a/modules/gdscript/tests/scripts/analyzer/features/null_initializer.gd
+++ b/modules/gdscript/tests/scripts/analyzer/features/null_initializer.gd
@@ -6,10 +6,12 @@ var prop = null
func check_arg(arg = null) -> void:
if arg != null:
+ @warning_ignore("unsafe_call_argument")
print(check(arg))
func check_recur() -> void:
if recur != null:
+ @warning_ignore("unsafe_call_argument")
print(check(recur))
else:
recur = 1
@@ -22,11 +24,13 @@ func test() -> void:
if prop == null:
set('prop', 1)
+ @warning_ignore("unsafe_call_argument")
print(check(prop))
set('prop', null)
var loop = null
while loop != 2:
if loop != null:
+ @warning_ignore("unsafe_call_argument")
print(check(loop))
loop = 1 if loop == null else 2
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.gd b/modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.gd
index 849df0921e..c1776fe1b4 100644
--- a/modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.gd
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.gd
@@ -14,4 +14,5 @@ func test():
func do_add_node():
var node = Node.new()
node.name = "Node"
+ @warning_ignore("unsafe_call_argument")
add_child(node)
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/unsafe_call_argument.gd b/modules/gdscript/tests/scripts/analyzer/warnings/unsafe_call_argument.gd
new file mode 100644
index 0000000000..573060ae0f
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/unsafe_call_argument.gd
@@ -0,0 +1,37 @@
+func variant_func(x: Variant) -> void:
+ print(x)
+
+func int_func(x: int) -> void:
+ print(x)
+
+func float_func(x: float) -> void:
+ print(x)
+
+# We don't want to execute it because of errors, just analyze.
+func no_exec_test():
+ 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.
+
+func test():
+ pass
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/unsafe_call_argument.out b/modules/gdscript/tests/scripts/analyzer/warnings/unsafe_call_argument.out
new file mode 100644
index 0000000000..b8fcb67158
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/unsafe_call_argument.out
@@ -0,0 +1,33 @@
+GDTEST_OK
+>> WARNING
+>> Line: 24
+>> UNSAFE_CALL_ARGUMENT
+>> The argument 1 of the function "int_func()" requires the subtype "int" but the supertype "Variant" was provided.
+>> WARNING
+>> Line: 25
+>> UNSAFE_CALL_ARGUMENT
+>> The argument 1 of the function "int_func()" requires the subtype "int" but the supertype "Variant" was provided.
+>> WARNING
+>> Line: 26
+>> UNSAFE_CALL_ARGUMENT
+>> The argument 1 of the function "int_func()" requires the subtype "int" but the supertype "Variant" was provided.
+>> WARNING
+>> Line: 27
+>> UNSAFE_CALL_ARGUMENT
+>> The argument 1 of the function "int_func()" requires the subtype "int" but the supertype "Variant" was provided.
+>> WARNING
+>> Line: 30
+>> UNSAFE_CALL_ARGUMENT
+>> The argument 1 of the function "float_func()" requires the subtype "float" but the supertype "Variant" was provided.
+>> WARNING
+>> Line: 31
+>> UNSAFE_CALL_ARGUMENT
+>> The argument 1 of the function "float_func()" requires the subtype "float" but the supertype "Variant" was provided.
+>> WARNING
+>> Line: 32
+>> UNSAFE_CALL_ARGUMENT
+>> The argument 1 of the function "float_func()" requires the subtype "float" but the supertype "Variant" was provided.
+>> WARNING
+>> Line: 33
+>> UNSAFE_CALL_ARGUMENT
+>> The argument 1 of the function "float_func()" requires the subtype "float" but the supertype "Variant" was provided.
diff --git a/modules/gdscript/tests/scripts/parser/errors/match_guard_with_assignment.gd b/modules/gdscript/tests/scripts/parser/errors/match_guard_with_assignment.gd
new file mode 100644
index 0000000000..d88b4a37c4
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/errors/match_guard_with_assignment.gd
@@ -0,0 +1,5 @@
+func test():
+ var a = 0
+ match a:
+ 0 when a = 1:
+ print("assignment not allowed on pattern guard")
diff --git a/modules/gdscript/tests/scripts/parser/errors/match_guard_with_assignment.out b/modules/gdscript/tests/scripts/parser/errors/match_guard_with_assignment.out
new file mode 100644
index 0000000000..e8f9130706
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/errors/match_guard_with_assignment.out
@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Assignment is not allowed inside an expression.
diff --git a/modules/gdscript/tests/scripts/parser/features/allowed_keywords_as_identifiers.gd b/modules/gdscript/tests/scripts/parser/features/allowed_keywords_as_identifiers.gd
index 7e1982597c..0c8a5d1367 100644
--- a/modules/gdscript/tests/scripts/parser/features/allowed_keywords_as_identifiers.gd
+++ b/modules/gdscript/tests/scripts/parser/features/allowed_keywords_as_identifiers.gd
@@ -14,3 +14,7 @@ func test():
var TAU = "TAU"
print(TAU)
+
+ # New keyword for pattern guards.
+ var when = "when"
+ print(when)
diff --git a/modules/gdscript/tests/scripts/parser/features/allowed_keywords_as_identifiers.out b/modules/gdscript/tests/scripts/parser/features/allowed_keywords_as_identifiers.out
index aae2ae13d5..8ac8e92ef7 100644
--- a/modules/gdscript/tests/scripts/parser/features/allowed_keywords_as_identifiers.out
+++ b/modules/gdscript/tests/scripts/parser/features/allowed_keywords_as_identifiers.out
@@ -4,3 +4,4 @@ PI
INF
NAN
TAU
+when
diff --git a/modules/gdscript/tests/scripts/parser/features/dollar_and_percent_get_node.gd b/modules/gdscript/tests/scripts/parser/features/dollar_and_percent_get_node.gd
index f04f4de08d..19f6e08285 100644
--- a/modules/gdscript/tests/scripts/parser/features/dollar_and_percent_get_node.gd
+++ b/modules/gdscript/tests/scripts/parser/features/dollar_and_percent_get_node.gd
@@ -3,27 +3,32 @@ extends Node
func test():
var child = Node.new()
child.name = "Child"
+ @warning_ignore("unsafe_call_argument")
add_child(child)
child.owner = self
var hey = Node.new()
hey.name = "Hey"
+ @warning_ignore("unsafe_call_argument")
child.add_child(hey)
hey.owner = self
hey.unique_name_in_owner = true
var fake_hey = Node.new()
fake_hey.name = "Hey"
+ @warning_ignore("unsafe_call_argument")
add_child(fake_hey)
fake_hey.owner = self
var sub_child = Node.new()
sub_child.name = "SubChild"
+ @warning_ignore("unsafe_call_argument")
hey.add_child(sub_child)
sub_child.owner = self
var howdy = Node.new()
howdy.name = "Howdy"
+ @warning_ignore("unsafe_call_argument")
sub_child.add_child(howdy)
howdy.owner = self
howdy.unique_name_in_owner = true
diff --git a/modules/gdscript/tests/scripts/parser/features/dollar_node_paths.gd b/modules/gdscript/tests/scripts/parser/features/dollar_node_paths.gd
index 8ba558e91d..3d9404b20b 100644
--- a/modules/gdscript/tests/scripts/parser/features/dollar_node_paths.gd
+++ b/modules/gdscript/tests/scripts/parser/features/dollar_node_paths.gd
@@ -5,9 +5,11 @@ func test():
# Create the required node structure.
var hello = Node.new()
hello.name = "Hello"
+ @warning_ignore("unsafe_call_argument")
add_child(hello)
var world = Node.new()
world.name = "World"
+ @warning_ignore("unsafe_call_argument")
hello.add_child(world)
# All the ways of writing node paths below with the `$` operator are valid.
diff --git a/modules/gdscript/tests/scripts/parser/features/lambda_ends_with_new_line.gd b/modules/gdscript/tests/scripts/parser/features/lambda_ends_with_new_line.gd
index df6001c7e2..f16c768f7f 100644
--- a/modules/gdscript/tests/scripts/parser/features/lambda_ends_with_new_line.gd
+++ b/modules/gdscript/tests/scripts/parser/features/lambda_ends_with_new_line.gd
@@ -26,6 +26,7 @@ func test():
if true: (v as Callable).call()
print()
+ @warning_ignore("unsafe_call_argument")
other(v)
print()
diff --git a/modules/gdscript/tests/scripts/parser/features/nested_function_calls.gd b/modules/gdscript/tests/scripts/parser/features/nested_function_calls.gd
index 59cdc7d6c2..31de73813f 100644
--- a/modules/gdscript/tests/scripts/parser/features/nested_function_calls.gd
+++ b/modules/gdscript/tests/scripts/parser/features/nested_function_calls.gd
@@ -2,4 +2,5 @@ func foo(x):
return x + 1
func test():
+ @warning_ignore("unsafe_call_argument")
print(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(0)))))))))))))))))))))))))
diff --git a/modules/gdscript/tests/scripts/parser/features/super.gd b/modules/gdscript/tests/scripts/parser/features/super.gd
index f5ae2a74a7..33accd92a9 100644
--- a/modules/gdscript/tests/scripts/parser/features/super.gd
+++ b/modules/gdscript/tests/scripts/parser/features/super.gd
@@ -36,6 +36,7 @@ class SayNothing extends Say:
print("howdy, see above")
func say(name):
+ @warning_ignore("unsafe_call_argument")
super(name + " super'd")
print(prefix, " say nothing... or not? ", name)
diff --git a/modules/gdscript/tests/scripts/parser/features/unicode_identifiers.gd b/modules/gdscript/tests/scripts/parser/features/unicode_identifiers.gd
index 523959a016..20cc0cee2e 100644
--- a/modules/gdscript/tests/scripts/parser/features/unicode_identifiers.gd
+++ b/modules/gdscript/tests/scripts/parser/features/unicode_identifiers.gd
@@ -29,6 +29,7 @@ func test():
const d = 1.1
_process(d)
+ @warning_ignore("unsafe_call_argument")
print(is_equal_approx(ㄥ, PI + (d * PI)))
func _process(Δ: float) -> void:
diff --git a/modules/gdscript/tests/scripts/runtime/features/for_loop_iterator_specified_types.gd b/modules/gdscript/tests/scripts/runtime/features/for_loop_iterator_specified_types.gd
index 58b4df5a79..bc899a3a6f 100644
--- a/modules/gdscript/tests/scripts/runtime/features/for_loop_iterator_specified_types.gd
+++ b/modules/gdscript/tests/scripts/runtime/features/for_loop_iterator_specified_types.gd
@@ -21,6 +21,12 @@ func test():
var elem := e
prints(var_to_str(e), var_to_str(elem))
+ # GH-82021
+ print("Test implicitly typed array literal.")
+ for e: float in [100, 200, 300]:
+ var elem := e
+ prints(var_to_str(e), var_to_str(elem))
+
print("Test String-keys dictionary.")
var d1 := {a = 1, b = 2, c = 3}
for k: StringName in d1:
diff --git a/modules/gdscript/tests/scripts/runtime/features/for_loop_iterator_specified_types.out b/modules/gdscript/tests/scripts/runtime/features/for_loop_iterator_specified_types.out
index f67f7d89d5..eeebdc4be5 100644
--- a/modules/gdscript/tests/scripts/runtime/features/for_loop_iterator_specified_types.out
+++ b/modules/gdscript/tests/scripts/runtime/features/for_loop_iterator_specified_types.out
@@ -15,6 +15,10 @@ Test typed int array.
10.0 10.0
20.0 20.0
30.0 30.0
+Test implicitly typed array literal.
+100.0 100.0
+200.0 200.0
+300.0 300.0
Test String-keys dictionary.
&"a" &"a"
&"b" &"b"
diff --git a/modules/gdscript/tests/scripts/runtime/features/match_with_pattern_guards.gd b/modules/gdscript/tests/scripts/runtime/features/match_with_pattern_guards.gd
new file mode 100644
index 0000000000..4cb51f8512
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/match_with_pattern_guards.gd
@@ -0,0 +1,71 @@
+var global := 0
+
+func test():
+ var a = 0
+ var b = 1
+
+ match a:
+ 0 when b == 0:
+ print("does not run" if true else "")
+ 0 when b == 1:
+ print("guards work")
+ _:
+ print("does not run")
+
+ match a:
+ var a_bind when b == 0:
+ prints("a is", a_bind, "and b is 0")
+ var a_bind when b == 1:
+ prints("a is", a_bind, "and b is 1")
+ _:
+ print("does not run")
+
+ match a:
+ var a_bind when a_bind < 0:
+ print("a is less than zero")
+ var a_bind when a_bind == 0:
+ print("a is equal to zero")
+ _:
+ print("a is more than zero")
+
+ match [1, 2, 3]:
+ [1, 2, var element] when element == 0:
+ print("does not run")
+ [1, 2, var element] when element == 3:
+ print("3rd element is 3")
+
+ match a:
+ _ when b == 0:
+ print("does not run")
+ _ when b == 1:
+ print("works with wildcard too.")
+ _:
+ print("does not run")
+
+ match a:
+ 0, 1 when b == 0:
+ print("does not run")
+ 0, 1 when b == 1:
+ print("guard with multiple patterns")
+ _:
+ print("does not run")
+
+ match a:
+ 0 when b == 0:
+ print("does not run")
+ 0:
+ print("regular pattern after guard mismatch")
+
+ match a:
+ 1 when side_effect():
+ print("should not run the side effect call")
+ 0 when side_effect():
+ print("will run the side effect call, but not this")
+ _:
+ assert(global == 1)
+ print("side effect only ran once")
+
+func side_effect():
+ print("side effect")
+ global += 1
+ return false
diff --git a/modules/gdscript/tests/scripts/runtime/features/match_with_pattern_guards.out b/modules/gdscript/tests/scripts/runtime/features/match_with_pattern_guards.out
new file mode 100644
index 0000000000..452d1ff4bf
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/match_with_pattern_guards.out
@@ -0,0 +1,10 @@
+GDTEST_OK
+guards work
+a is 0 and b is 1
+a is equal to zero
+3rd element is 3
+works with wildcard too.
+guard with multiple patterns
+regular pattern after guard mismatch
+side effect
+side effect only ran once
diff --git a/modules/gdscript/tests/scripts/runtime/features/member_info_inheritance.gd b/modules/gdscript/tests/scripts/runtime/features/member_info_inheritance.gd
new file mode 100644
index 0000000000..d0cbeeab85
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/member_info_inheritance.gd
@@ -0,0 +1,45 @@
+# GH-82169
+
+const Utils = preload("../../utils.notest.gd")
+
+class A:
+ static var test_static_var_a1
+ static var test_static_var_a2
+ var test_var_a1
+ var test_var_a2
+ static func test_static_func_a1(): pass
+ static func test_static_func_a2(): pass
+ func test_func_a1(): pass
+ func test_func_a2(): pass
+ signal test_signal_a1()
+ signal test_signal_a2()
+
+class B extends A:
+ static var test_static_var_b1
+ static var test_static_var_b2
+ var test_var_b1
+ var test_var_b2
+ static func test_static_func_b1(): pass
+ static func test_static_func_b2(): pass
+ func test_func_b1(): pass
+ func test_func_b2(): pass
+ signal test_signal_b1()
+ signal test_signal_b2()
+
+func test():
+ var b := B.new()
+ for property in (B as GDScript).get_property_list():
+ if str(property.name).begins_with("test_"):
+ print(Utils.get_property_signature(property, true))
+ print("---")
+ for property in b.get_property_list():
+ if str(property.name).begins_with("test_"):
+ print(Utils.get_property_signature(property))
+ print("---")
+ for method in b.get_method_list():
+ if str(method.name).begins_with("test_"):
+ print(Utils.get_method_signature(method))
+ print("---")
+ for method in b.get_signal_list():
+ if str(method.name).begins_with("test_"):
+ print(Utils.get_method_signature(method, true))
diff --git a/modules/gdscript/tests/scripts/runtime/features/member_info_inheritance.out b/modules/gdscript/tests/scripts/runtime/features/member_info_inheritance.out
new file mode 100644
index 0000000000..f294b66ef9
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/member_info_inheritance.out
@@ -0,0 +1,24 @@
+GDTEST_OK
+static var test_static_var_a1: Variant
+static var test_static_var_a2: Variant
+static var test_static_var_b1: Variant
+static var test_static_var_b2: Variant
+---
+var test_var_b1: Variant
+var test_var_b2: Variant
+var test_var_a1: Variant
+var test_var_a2: Variant
+---
+static func test_static_func_b1() -> void
+static func test_static_func_b2() -> void
+func test_func_b1() -> void
+func test_func_b2() -> void
+static func test_static_func_a1() -> void
+static func test_static_func_a2() -> void
+func test_func_a1() -> void
+func test_func_a2() -> void
+---
+signal test_signal_b1()
+signal test_signal_b2()
+signal test_signal_a1()
+signal test_signal_a2()
diff --git a/modules/gdscript/tests/scripts/runtime/features/object_constructor.gd b/modules/gdscript/tests/scripts/runtime/features/object_constructor.gd
new file mode 100644
index 0000000000..b875efef56
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/object_constructor.gd
@@ -0,0 +1,6 @@
+# GH-73213
+
+func test():
+ var object := Object.new() # Not `Object()`.
+ print(object.get_class())
+ object.free()
diff --git a/modules/gdscript/tests/scripts/runtime/features/object_constructor.out b/modules/gdscript/tests/scripts/runtime/features/object_constructor.out
new file mode 100644
index 0000000000..3673881576
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/object_constructor.out
@@ -0,0 +1,2 @@
+GDTEST_OK
+Object
diff --git a/modules/gdscript/tests/scripts/runtime/features/standalone-calls-do-not-write-to-nil.gd b/modules/gdscript/tests/scripts/runtime/features/standalone-calls-do-not-write-to-nil.gd
index 2f55059334..fd1460a48f 100644
--- a/modules/gdscript/tests/scripts/runtime/features/standalone-calls-do-not-write-to-nil.gd
+++ b/modules/gdscript/tests/scripts/runtime/features/standalone-calls-do-not-write-to-nil.gd
@@ -12,6 +12,7 @@ func test():
print("end")
func test_construct(v, f):
+ @warning_ignore("unsafe_call_argument")
Vector2(v, v) # Built-in type construct.
assert(not f) # Test unary operator reading from `nil`.
diff --git a/modules/gdscript/tests/scripts/runtime/features/static_variables.gd b/modules/gdscript/tests/scripts/runtime/features/static_variables.gd
index 8da8bb7e53..7fa76ca4b0 100644
--- a/modules/gdscript/tests/scripts/runtime/features/static_variables.gd
+++ b/modules/gdscript/tests/scripts/runtime/features/static_variables.gd
@@ -44,6 +44,7 @@ func test():
@warning_ignore("unsafe_method_access")
var path = get_script().get_path().get_base_dir()
+ @warning_ignore("unsafe_call_argument")
var other = load(path + "/static_variables_load.gd")
prints("load.perm:", other.perm)
diff --git a/modules/gdscript/tests/scripts/runtime/features/stringify.gd b/modules/gdscript/tests/scripts/runtime/features/stringify.gd
index fead2df854..1e66d8f34a 100644
--- a/modules/gdscript/tests/scripts/runtime/features/stringify.gd
+++ b/modules/gdscript/tests/scripts/runtime/features/stringify.gd
@@ -24,7 +24,8 @@ func test():
print(StringName("hello"))
print(NodePath("hello/world"))
var node := Node.new()
- print(RID(node))
+ @warning_ignore("unsafe_call_argument")
+ print(RID(node)) # TODO: Why is the constructor (or implicit cast) not documented?
print(node.get_name)
print(node.property_list_changed)
node.free()
diff --git a/modules/gdscript/tests/scripts/utils.notest.gd b/modules/gdscript/tests/scripts/utils.notest.gd
index fb20817117..781843b8e2 100644
--- a/modules/gdscript/tests/scripts/utils.notest.gd
+++ b/modules/gdscript/tests/scripts/utils.notest.gd
@@ -17,7 +17,7 @@ static func get_type(property: Dictionary, is_return: bool = false) -> String:
TYPE_OBJECT:
if not str(property.class_name).is_empty():
return property.class_name
- return variant_get_type_name(property.type)
+ return type_string(property.type)
static func get_property_signature(property: Dictionary, is_static: bool = false) -> String:
@@ -66,88 +66,6 @@ static func get_method_signature(method: Dictionary, is_signal: bool = false) ->
return result
-static func variant_get_type_name(type: Variant.Type) -> String:
- match type:
- TYPE_NIL:
- return "Nil" # `Nil` in core, `null` in GDScript.
- TYPE_BOOL:
- return "bool"
- TYPE_INT:
- return "int"
- TYPE_FLOAT:
- return "float"
- TYPE_STRING:
- return "String"
- TYPE_VECTOR2:
- return "Vector2"
- TYPE_VECTOR2I:
- return "Vector2i"
- TYPE_RECT2:
- return "Rect2"
- TYPE_RECT2I:
- return "Rect2i"
- TYPE_VECTOR3:
- return "Vector3"
- TYPE_VECTOR3I:
- return "Vector3i"
- TYPE_TRANSFORM2D:
- return "Transform2D"
- TYPE_VECTOR4:
- return "Vector4"
- TYPE_VECTOR4I:
- return "Vector4i"
- TYPE_PLANE:
- return "Plane"
- TYPE_QUATERNION:
- return "Quaternion"
- TYPE_AABB:
- return "AABB"
- TYPE_BASIS:
- return "Basis"
- TYPE_TRANSFORM3D:
- return "Transform3D"
- TYPE_PROJECTION:
- return "Projection"
- TYPE_COLOR:
- return "Color"
- TYPE_STRING_NAME:
- return "StringName"
- TYPE_NODE_PATH:
- return "NodePath"
- TYPE_RID:
- return "RID"
- TYPE_OBJECT:
- return "Object"
- TYPE_CALLABLE:
- return "Callable"
- TYPE_SIGNAL:
- return "Signal"
- TYPE_DICTIONARY:
- return "Dictionary"
- TYPE_ARRAY:
- return "Array"
- TYPE_PACKED_BYTE_ARRAY:
- return "PackedByteArray"
- TYPE_PACKED_INT32_ARRAY:
- return "PackedInt32Array"
- TYPE_PACKED_INT64_ARRAY:
- return "PackedInt64Array"
- TYPE_PACKED_FLOAT32_ARRAY:
- return "PackedFloat32Array"
- TYPE_PACKED_FLOAT64_ARRAY:
- return "PackedFloat64Array"
- TYPE_PACKED_STRING_ARRAY:
- return "PackedStringArray"
- TYPE_PACKED_VECTOR2_ARRAY:
- return "PackedVector2Array"
- TYPE_PACKED_VECTOR3_ARRAY:
- return "PackedVector3Array"
- TYPE_PACKED_COLOR_ARRAY:
- return "PackedColorArray"
- push_error("Argument `type` is invalid. Use `TYPE_*` constants.")
- return "<invalid type>"
-
-
static func get_property_hint_name(hint: PropertyHint) -> String:
match hint:
PROPERTY_HINT_NONE: