GDScript: Fix missing conversion for default argument values
This commit is contained in:
parent
b14f7aa9f9
commit
a8c2f8a0e1
10 changed files with 56 additions and 12 deletions
|
|
@ -0,0 +1,8 @@
|
|||
var weakling = 'not float'
|
||||
func weak(x: float = weakling):
|
||||
print(x)
|
||||
print('typeof x is', typeof(x))
|
||||
|
||||
func test():
|
||||
print(typeof(weak()))
|
||||
print('not ok')
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
GDTEST_RUNTIME_ERROR
|
||||
>> SCRIPT ERROR
|
||||
>> on function: weak()
|
||||
>> runtime/errors/bad_conversion_for_default_parameter.gd
|
||||
>> 2
|
||||
>> Trying to assign value of type 'String' to a variable of type 'float'.
|
||||
0
|
||||
not ok
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
func literal(x: float = 1):
|
||||
print('x is ', x)
|
||||
print('typeof x is ', typeof(x))
|
||||
|
||||
var inferring := 2
|
||||
func inferred(x: float = inferring):
|
||||
print('x is ', x)
|
||||
print('typeof x is ', typeof(x))
|
||||
|
||||
var weakling = 3
|
||||
func weak(x: float = weakling):
|
||||
print('x is ', x)
|
||||
print('typeof x is ', typeof(x))
|
||||
|
||||
func test():
|
||||
literal()
|
||||
inferred()
|
||||
weak()
|
||||
print('ok')
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
GDTEST_OK
|
||||
x is 1
|
||||
typeof x is 3
|
||||
x is 2
|
||||
typeof x is 3
|
||||
x is 3
|
||||
typeof x is 3
|
||||
ok
|
||||
Loading…
Add table
Add a link
Reference in a new issue