You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we have strange behaviour of annotated function arguments.
With some argument types (number, integer, number[], integer[], table) you can't pass nil, you will get a type error.
But with other types -- string, closure, userdata -- you can pass nil without any errors.
Example:
functiontest(a: number)
print(a)
endtest()
ravi: t.lua:0: TOFLT: number expected
Another example:
functiontest(a: closure)
print(a)
endtest()
nil (no error thrown)
I think behaviour of annotated arguments should be unified.
Most obvious solution is to make all arguments with specified type -- mandatory. (it is already that in JIT mode: #225)
In case when argument must be optional -- we have any type (or just omit annotation) as for now.
The text was updated successfully, but these errors were encountered:
I have pushed some changes to make it consistent between the JIT and the interpreter. For now, this continues the existing model in the VM that NIL is valid value for Lua types - the Ravi add-on types do not allow NIL.
Hello.
Let's summarize our discussion on that.
Currently we have strange behaviour of annotated function arguments.
With some argument types (
number
,integer
,number[]
,integer[]
,table
) you can't passnil
, you will get a type error.But with other types --
string
,closure
,userdata
-- you can passnil
without any errors.Example:
ravi: t.lua:0: TOFLT: number expected
Another example:
nil
(no error thrown)I think behaviour of annotated arguments should be unified.
Most obvious solution is to make all arguments with specified type -- mandatory. (it is already that in JIT mode: #225)
In case when argument must be optional -- we have
any
type (or just omit annotation) as for now.The text was updated successfully, but these errors were encountered: