Merge pull request #84043 from dalexeev/gds-fix-unsafe-cast-warning
GDScript: Fix `UNSAFE_CAST` warning
This commit is contained in:
commit
f8ca571efe
22 changed files with 150 additions and 6 deletions
|
|
@ -0,0 +1,4 @@
|
|||
func test():
|
||||
var node := Node.new()
|
||||
node.free()
|
||||
print(node as Node2D)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
GDTEST_RUNTIME_ERROR
|
||||
>> SCRIPT ERROR
|
||||
>> on function: test()
|
||||
>> runtime/errors/cast_freed_object.gd
|
||||
>> 4
|
||||
>> Trying to cast a freed object.
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
func test():
|
||||
var integer: Variant = 1
|
||||
@warning_ignore("unsafe_cast")
|
||||
print(integer as Array)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
GDTEST_RUNTIME_ERROR
|
||||
>> SCRIPT ERROR
|
||||
>> on function: test()
|
||||
>> runtime/errors/cast_int_to_array.gd
|
||||
>> 4
|
||||
>> Invalid cast: could not convert value to 'Array'.
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
func test():
|
||||
var integer: Variant = 1
|
||||
@warning_ignore("unsafe_cast")
|
||||
print(integer as Node)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
GDTEST_RUNTIME_ERROR
|
||||
>> SCRIPT ERROR
|
||||
>> on function: test()
|
||||
>> runtime/errors/cast_int_to_object.gd
|
||||
>> 4
|
||||
>> Invalid cast: can't convert a non-object value to an object type.
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
func test():
|
||||
var object: Variant = RefCounted.new()
|
||||
@warning_ignore("unsafe_cast")
|
||||
print(object as int)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
GDTEST_RUNTIME_ERROR
|
||||
>> SCRIPT ERROR
|
||||
>> on function: test()
|
||||
>> runtime/errors/cast_object_to_int.gd
|
||||
>> 4
|
||||
>> Invalid cast: could not convert value to 'int'.
|
||||
Loading…
Add table
Add a link
Reference in a new issue