Add some very primitive type narrowing for global functions.
General syntax:
if type(doSomething) = "roFunction" then
doSomething()
end if
You must wrap your function with an if statement that includes one or both of these conditions, but must contain no other conditions. Like this:
if type(theThing) = "roFunction"
if type(theThing) = "Function"
if type(theThing) = "roFunction" or type(theThing) = "Function"
The order may also be swapped. Like this:
if type(theThing) = "roFunction"
if "roFunction" = type(theThing)
The way we will implement this in v0 is:
when we're about to add the cannot find name diagnostic, we will walk up the ast tree looking at every if statement. if it matches one of the syntaxes above, then we will NOT add the diagnostic.
NOTE: this is NOT a broad type guard implementation, and is exclusively for global functions
Add some very primitive type narrowing for global functions.
General syntax:
You must wrap your function with an
if
statement that includes one or both of these conditions, but must contain no other conditions. Like this:The order may also be swapped. Like this:
The way we will implement this in v0 is:
cannot find name
diagnostic, we will walk up the ast tree looking at every if statement. if it matches one of the syntaxes above, then we will NOT add the diagnostic.NOTE: this is NOT a broad type guard implementation, and is exclusively for global functions