Open sjbarag opened 4 years ago
Another scenario with this same unboxing issue can be reproduced this way: brs> a = CreateObject("roInt",1) brs> ? a+1 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:
brs> a = CreateObject("roInt",1) brs> ? a 1 brs> ? a=1 false
In #365 and #360 we realized that 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 primitive string and never an instance ofroString
. Similarly, the return value ofunboxing
is also always a primitive string and never an instance ofroString
.brs
currently doesn't handle this demotion properly, and throws type mismatch errors at runtime 😢