Closed lvcabral closed 6 months ago
Another scenario with this same unboxing issue can be reproduced this way:
a = CreateObject("roInt",1)
? a+1
causes an error:
REPL(1,2-5): Attempting to add non-homogeneous values.
left: Object
right: Integer**
In case of a comparison is even worse, as it does not return an error so it silently return false
if you compare a roInt
with value 1
and the constant 1
like this:
a = CreateObject("roInt",1)
? a
1
? a=1
false
RBI automatically boxes function parameters and return values. As it turns out, RBI also unboxes function parameters and return values to match a function's declared signature. Consider this example:
Inside of the
unboxing
function,s
is always a primitivestring
and never an instance ofroString
. Similarly, the return value ofunboxing
is also always a primitivestring
and never an instance ofroString
.brs
currently doesn't handle this demotion properly, and throws type mismatch errors at runtime 😢