From e8696f9961e4d317f56ceb9626792529966f0e91 Mon Sep 17 00:00:00 2001 From: Danil Alexeev Date: Thu, 21 Sep 2023 12:42:55 +0300 Subject: GDScript: Improve call analysis * Add missing `UNSAFE_CALL_ARGUMENT` warning. * Fix `Object` constructor. * Display an error for non-existent static methods. --- .../scripts/analyzer/errors/call_not_existing_static_method.gd | 7 +++++++ .../scripts/analyzer/errors/call_not_existing_static_method.out | 2 ++ .../tests/scripts/analyzer/errors/object_invalid_constructor.gd | 4 ++++ .../tests/scripts/analyzer/errors/object_invalid_constructor.out | 2 ++ 4 files changed, 15 insertions(+) create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/call_not_existing_static_method.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/call_not_existing_static_method.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/object_invalid_constructor.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/object_invalid_constructor.out (limited to 'modules/gdscript/tests/scripts/analyzer/errors') 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/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. -- cgit v1.2.3