mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Merge pull request #75988 from dalexeev/gds-unsafe-call-argument
GDScript: Improve call analysis
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
@@ -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.
|
||||
Reference in New Issue
Block a user