Improved Wasm Error Messages

In response to some helpful feedback from @dreig, I’ve opened a PR to update WABT and ensure that validation is executed against the text-format, not the binary-format.

Previously, errors would look like this:

 Compiling function #0 failed: expected 2 elements on the stack for fallthru, found 4 @+57

where @+57 is a byte offset into the wasm binary.

Once my PR merges, it will look like this:

Error: validate failed:
    11:21: error: type mismatch at end of function, expected [] but got [i32, i32]
        (i32.const 64) (i32.const 14)
                               ^^^^^^

Where 11:21 will match the error in the source program that and the log will highlight the referenced line.

Given that this requires publishing a new library version to npm and updating the track, it will take a few days to go live.

Just wanted to give a heads up and a shoutout to @dreig for speaking up and digging into this! :clap::raised_hands:

5 Likes