GDScript: Avoid hard errors on inferred types
Since inference isn't always correct, they are now treated as unsafe instead of errors. This also removes inferred type when a variable is reassigned. Since it's not aware of branching, the types might become invalid in a later context.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
# https://github.com/godotengine/godot/issues/43503
|
||||
|
||||
var test_var = null
|
||||
|
||||
|
||||
func test():
|
||||
print(test_var.x)
|
||||
|
||||
|
||||
func _init():
|
||||
test_var = Vector3()
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
0
|
||||
@@ -0,0 +1,14 @@
|
||||
# https://github.com/godotengine/godot/issues/41064
|
||||
var x = true
|
||||
|
||||
func test():
|
||||
var int_var: int = 0
|
||||
var dyn_var = 2
|
||||
|
||||
if x:
|
||||
dyn_var = 5
|
||||
else:
|
||||
dyn_var = Node.new()
|
||||
|
||||
int_var = dyn_var
|
||||
print(int_var)
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
5
|
||||
Reference in New Issue
Block a user