Optimise raise/1,2 at compile time

Where possible the type of the exception (1st argument) is inferred at
compile time instead of run time.
Merge pull request #1786 from fishcakez/optimise_raise

Optimise raise/1,2 at compile time