Open markwpearce opened 13 hours ago
Interestingly enough, the assignment itself is not the error. It's when you try to use it that it crashes. Like this:
thing1 = noop()
'this code is fine
if thing1 = invalid then
print "thing1 is invalid"
end if
thing2 = arr.Append([])
'this code will crash
if thing2 = invalid then
print "thing2 is invalid"
end if
Built in Brightscript functions that are
as void
do not return invalid like developer created functions.When you call built-in as void functions that are on the native roku objects, they return uninitialized. When you call developer-written as void functions, they return invalid. So the runtime behavior is different even though you'd expect as void to behave the same regardless of where they're defined. And since uninitialized causes runtime crashes when you try to read them and have slightly different rules than invalid, it's important to know when you're using uninitialized vs invalid.
To fix in V1 -- we could just make the doc scraper build a correct
TypedFunctionType
that returnsUninitializedType
when the return isas void
And then validate against uninitialized RHS of assignment statements.