-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75988 from dalexeev/gds-unsafe-call-argument
GDScript: Improve call analysis
- Loading branch information
Showing
25 changed files
with
184 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
modules/gdscript/tests/scripts/analyzer/errors/call_not_existing_static_method.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# GH-73283 | ||
|
||
class MyClass: | ||
pass | ||
|
||
func test(): | ||
MyClass.not_existing_method() |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/call_not_existing_static_method.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Static function "not_existing_method()" not found in base "MyClass". |
4 changes: 4 additions & 0 deletions
4
modules/gdscript/tests/scripts/analyzer/errors/object_invalid_constructor.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# GH-73213 | ||
|
||
func test(): | ||
print(Object()) |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/object_invalid_constructor.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Invalid constructor "Object()", use "Object.new()" instead. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
modules/gdscript/tests/scripts/analyzer/warnings/unsafe_call_argument.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.