ballercat / walt

:zap: Walt is a JavaScript-like syntax for WebAssembly text format :zap:
https://ballercat.github.io/walt/
MIT License
4.64k stars 122 forks source link

Support the throw keyword #152

Closed ballercat closed 6 years ago

ballercat commented 6 years ago

New Feature

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());
}