Skip to content

Throw syntax

Compare
Choose a tag to compare
@ballercat ballercat released this 09 Oct 22:56
· 38 commits to master since this release

This PR adds support for the throw keyword. It proxies to the unreachable instruction in the WebAssembly spec. As per spec nothing can be actually "thrown" with the runtime exception.

function test() {
   throw;
}

The syntax does reserve an expression after the throw keyword for future use so this code is also valid, although the expression is ignored after the throw.

function test() {
   // May throw the result of expression in the future if WebAssembly supports it
   throw somefunction(2 + 2, another());
}