GDScript: Improve call analysis

* Add missing `UNSAFE_CALL_ARGUMENT` warning.
* Fix `Object` constructor.
* Display an error for non-existent static methods.
This commit is contained in:
Danil Alexeev
2023-09-21 12:42:55 +03:00
parent 59139df16e
commit e8696f9961
25 changed files with 184 additions and 46 deletions

View File

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

View File

@@ -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.

View File

@@ -26,6 +26,7 @@ func test():
if true: (v as Callable).call()
print()
@warning_ignore("unsafe_call_argument")
other(v)
print()

View File

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

View File

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

View File

@@ -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: