GDScript: Add static typing for for loop variable
This commit is contained in:
parent
0511f9d9a7
commit
6c59ed9485
20 changed files with 177 additions and 17 deletions
|
|
@ -0,0 +1,4 @@
|
|||
func test():
|
||||
var a: Array[Resource] = []
|
||||
for node: Node in a:
|
||||
print(node)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_ANALYZER_ERROR
|
||||
Unable to iterate on value of type "Array[Resource]" with variable of type "Node".
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
func test():
|
||||
var a: Array[Node] = []
|
||||
for node: Node in a:
|
||||
print(node)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
GDTEST_OK
|
||||
>> WARNING
|
||||
>> Line: 3
|
||||
>> REDUNDANT_FOR_VARIABLE_TYPE
|
||||
>> The for loop iterator "node" already has inferred type "Node", the specified type is redundant.
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
func test():
|
||||
var a: Array[Node2D] = []
|
||||
for node: Node in a:
|
||||
print(node)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
GDTEST_OK
|
||||
>> WARNING
|
||||
>> Line: 3
|
||||
>> REDUNDANT_FOR_VARIABLE_TYPE
|
||||
>> The for loop iterator "node" has inferred type "Node2D" but its supertype "Node" is specified.
|
||||
Loading…
Add table
Add a link
Reference in a new issue