Support the raise statement
Closed this issue · 1 comments
breuleux commented
I do not believe we should support try/except in Myia, at least not in the foreseeable future, but support for raise
would be useful. raise
would basically abort the whole program with an informative message.
My idea to implement this is to add the raise_
and Exception
primitives.
Exception(message, *args)
would have some special type likeAbstractException
, which for now might not support any operations on it.raise_(x)
would be produced by the parser when it seesraise x
. It would have the typeAbstractBottom
. "bottom" in type theory is the type that has no values, so it's the type of infinite loops and errors.amerge(AbstractBottom, x)
andamerge(x, AbstractBottom)
should succeed and return x (because it either returns x or brings down the whole program). That way,raise
can be put in a branch of a conditional and the inferrer will not complain.