GDScript: Fix issues with typed arrays

This commit is contained in:
Dmitrii Maganov
2022-11-27 09:56:53 +02:00
parent e9de988020
commit 5909f9f075
50 changed files with 959 additions and 555 deletions

View File

@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot get index "true" from "[0, 1]".
Invalid index type "bool" for a base of type "Array".

View File

@@ -0,0 +1,4 @@
func test():
var differently: Array[float] = [1.0]
var typed: Array[int] = differently
print('not ok')

View File

@@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot assign a value of type Array[float] to variable "typed" with specified type Array[int].

View File

@@ -0,0 +1,2 @@
func test():
const arr: Array[int] = ["Hello", "World"]

View File

@@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot include a value of type "String" as "int".

View File

@@ -0,0 +1,4 @@
func test():
var unconvertable := 1
var typed: Array[Object] = [unconvertable]
print('not ok')

View File

@@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot have an element of type "int" in an array of type "Array[Object]".

View File

@@ -0,0 +1,7 @@
func expect_typed(typed: Array[int]):
print(typed.size())
func test():
var differently: Array[float] = [1.0]
expect_typed(differently)
print('not ok')

View File

@@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
Invalid argument for "expect_typed()" function: argument 1 should be "Array[int]" but is "Array[float]".