-
-
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 #72608 from vnen/gdscript-warning-default-error
GDScript: Add warnings that are set to error by default (take 2)
- Loading branch information
Showing
22 changed files
with
371 additions
and
57 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
2 changes: 1 addition & 1 deletion
2
...scripts/analyzer/errors/function_dont_match_parent_signature_parameter_default_values.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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
The function signature doesn't match the parent. Parent signature is "my_function(int = default) -> int". | ||
The function signature doesn't match the parent. Parent signature is "my_function(int = <default>) -> int". |
18 changes: 18 additions & 0 deletions
18
modules/gdscript/tests/scripts/analyzer/features/allow_get_node_with_onready.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,18 @@ | ||
extends Node | ||
|
||
@onready var shorthand = $Node | ||
@onready var call = get_node(^"Node") | ||
@onready var shorthand_with_cast = $Node as Node | ||
@onready var call_with_cast = get_node(^"Node") as Node | ||
|
||
func _init(): | ||
var node := Node.new() | ||
node.name = "Node" | ||
add_child(node) | ||
|
||
func test(): | ||
# Those are expected to be `null` since `_ready()` is never called on tests. | ||
prints("shorthand", shorthand) | ||
prints("call", call) | ||
prints("shorthand_with_cast", shorthand_with_cast) | ||
prints("call_with_cast", call_with_cast) |
5 changes: 5 additions & 0 deletions
5
modules/gdscript/tests/scripts/analyzer/features/allow_get_node_with_onready.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,5 @@ | ||
GDTEST_OK | ||
shorthand <null> | ||
call <null> | ||
shorthand_with_cast <null> | ||
call_with_cast <null> |
13 changes: 13 additions & 0 deletions
13
modules/gdscript/tests/scripts/analyzer/features/assign_to_native_enum_property.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,13 @@ | ||
# https://github.com/godotengine/godot/issues/72501 | ||
extends Node | ||
|
||
func test(): | ||
prints("before", process_mode) | ||
process_mode = PROCESS_MODE_PAUSABLE | ||
prints("after", process_mode) | ||
|
||
var node := Node.new() | ||
add_child(node) | ||
prints("before", node.process_mode) | ||
node.process_mode = PROCESS_MODE_PAUSABLE | ||
prints("after", node.process_mode) |
5 changes: 5 additions & 0 deletions
5
modules/gdscript/tests/scripts/analyzer/features/assign_to_native_enum_property.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,5 @@ | ||
GDTEST_OK | ||
before 0 | ||
after 1 | ||
before 0 | ||
after 1 |
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
17 changes: 17 additions & 0 deletions
17
modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.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,17 @@ | ||
extends Node | ||
|
||
var add_node = do_add_node() # Hack to have one node on init and not fail at runtime. | ||
|
||
var shorthand = $Node | ||
var with_self = self.get_node(^"Node") | ||
var without_self = get_node(^"Node") | ||
var with_cast = get_node(^"Node") as Node | ||
var shorthand_with_cast = $Node as Node | ||
|
||
func test(): | ||
print("warn") | ||
|
||
func do_add_node(): | ||
var node = Node.new() | ||
node.name = "Node" | ||
add_child(node) |
22 changes: 22 additions & 0 deletions
22
modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.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,22 @@ | ||
GDTEST_OK | ||
>> WARNING | ||
>> Line: 5 | ||
>> GET_NODE_DEFAULT_WITHOUT_ONREADY | ||
>> The default value is using "$" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this. | ||
>> WARNING | ||
>> Line: 6 | ||
>> GET_NODE_DEFAULT_WITHOUT_ONREADY | ||
>> The default value is using "get_node()" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this. | ||
>> WARNING | ||
>> Line: 7 | ||
>> GET_NODE_DEFAULT_WITHOUT_ONREADY | ||
>> The default value is using "get_node()" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this. | ||
>> WARNING | ||
>> Line: 8 | ||
>> GET_NODE_DEFAULT_WITHOUT_ONREADY | ||
>> The default value is using "get_node()" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this. | ||
>> WARNING | ||
>> Line: 9 | ||
>> GET_NODE_DEFAULT_WITHOUT_ONREADY | ||
>> The default value is using "$" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this. | ||
warn |
6 changes: 6 additions & 0 deletions
6
modules/gdscript/tests/scripts/analyzer/warnings/inference_with_variant.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,6 @@ | ||
func test(): | ||
var inferred_with_variant := return_variant() | ||
print(inferred_with_variant) | ||
|
||
func return_variant() -> Variant: | ||
return "warn" |
6 changes: 6 additions & 0 deletions
6
modules/gdscript/tests/scripts/analyzer/warnings/inference_with_variant.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,6 @@ | ||
GDTEST_OK | ||
>> WARNING | ||
>> Line: 2 | ||
>> INFERENCE_ON_VARIANT | ||
>> The variable type is being inferred from a Variant value, so it will be typed as Variant. | ||
warn |
6 changes: 6 additions & 0 deletions
6
modules/gdscript/tests/scripts/analyzer/warnings/onready_with_export.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,6 @@ | ||
extends Node | ||
|
||
@onready @export var conflict = "" | ||
|
||
func test(): | ||
print("warn") |
6 changes: 6 additions & 0 deletions
6
modules/gdscript/tests/scripts/analyzer/warnings/onready_with_export.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,6 @@ | ||
GDTEST_OK | ||
>> WARNING | ||
>> Line: 3 | ||
>> ONREADY_WITH_EXPORT | ||
>> The "@onready" annotation will make the default value to be set after the "@export" takes effect and will override it. | ||
warn |
5 changes: 5 additions & 0 deletions
5
modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_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,5 @@ | ||
func test(): | ||
print("warn") | ||
|
||
func get(_property: StringName) -> Variant: | ||
return null |
6 changes: 6 additions & 0 deletions
6
modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_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,6 @@ | ||
GDTEST_OK | ||
>> WARNING | ||
>> Line: 4 | ||
>> NATIVE_METHOD_OVERRIDE | ||
>> The method "get" overrides a method from native class "Object". This won't be called by the engine and may not work as expected. | ||
warn |