1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

Unify typing of variables, constants and parameters in GDScript

This commit is contained in:
Dmitrii Maganov
2022-12-22 22:43:36 +02:00
parent 1d14c054a1
commit a1d06749f1
17 changed files with 237 additions and 357 deletions

View File

@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Value of type "MyOtherEnum (enum)" cannot be assigned to a variable of type "MyEnum (enum)".
Cannot assign a value of type MyOtherEnum (enum) to variable "class_var" with specified type MyEnum (enum).

View File

@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Value of type "MyOtherEnum (enum)" cannot be assigned to a variable of type "MyEnum (enum)".
Cannot assign a value of type MyOtherEnum (enum) to variable "local_var" with specified type MyEnum (enum).

View File

@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Value of type "int" cannot be assigned to a variable of type "String".
Cannot assign a value of type int to variable "x" with specified type String.

View File

@@ -0,0 +1,6 @@
func check(arg: float = 3):
return typeof(arg) == typeof(3.0)
func test():
if check():
print('ok')

View File

@@ -0,0 +1,2 @@
GDTEST_OK
ok

View File

@@ -0,0 +1,32 @@
func check(input: int) -> bool:
return input == 1
var recur = null
var prop = null
func check_arg(arg = null) -> void:
if arg != null:
print(check(arg))
func check_recur() -> void:
if recur != null:
print(check(recur))
else:
recur = 1
check_recur()
func test() -> void:
check_arg(1)
check_recur()
if prop == null:
set('prop', 1)
print(check(prop))
set('prop', null)
var loop = null
while loop != 2:
if loop != null:
print(check(loop))
loop = 1 if loop == null else 2

View File

@@ -0,0 +1,5 @@
GDTEST_OK
true
true
true
true

View File

@@ -0,0 +1,5 @@
func test():
var bar = 1
var foo: float = bar
print(typeof(foo))
print(foo is float)

View File

@@ -0,0 +1,3 @@
GDTEST_OK
3
true

View File

@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Assigned value for constant "arr" has type Array[String] which is not compatible with defined type Array[int].
Cannot assign a value of type Array[String] to constant "arr" with specified type Array[int].