wabt
wabt copied to clipboard
Module fails to compile without a proper error message
The following module fails to compile:
(module
(func (param externref) (result i32)
(ref.is_null)
)
)
Running wat2wasm on this leads to an exit code if 1, but no proper error message. Debugging with GDB shows that the typechecker throws an error here:
https://github.com/WebAssembly/wabt/blob/1edeaf2948b4afd711e50ba2007ee44503cd80fe/src/type-checker.cc#L814
The problem is, that even though the result is now set to an error, no error message is printed, as the PeekType function doesn't do so. This code is obviously not valid WASM (its missing a local.get 0 in front of ref.is_null), but I still would expect a proper error message.
Example with `i32.add`
(module
(func (param i32) (result i32)
(i32.add)
)
)
Gives a proper error message:
simple.wat:3:10: error: type mismatch in i32.add, expected [i32, i32] but got []
(i32.add)
^^^^^^^
(NOTE: After looking at the at the following the PeekType call, I assume the condition should have been type == Type::Any || !type.IsRef())
I think think assumption looks correct. Would you be able to send a PR to fix that line?
Currently on vacation, but sadly the fix isn't as simple as I thought (it can cause miscompilation in other cases if applied the way I suggested). I'll take a look when I'm home again
we think we can fix this...