Open agustinmista opened 3 years ago
Hi
Your PR is highly welcome.
Instead of silently return Nothing in eval
function I would throw an explicit error like error "Arguments mismatch"
in invoke
implementation. Besides arguments count I would check types of arguments too.
Hi!
I found a issue in the implementation of
eval/invoke
inLanguage.Wasm.Interpreter
.Right now, invocation arguments are only type-matched pairwise using
zipWith checkValType
. This silently drops any non-matched argument when the two lists have different length, providing confusing results because the indices of the locals get shifted to the left.For instance, if I do:
Then, invoking "foo" with a single argument doesn't fail, but instead it returns the value of the first zero-initialized local:
Running this in the reference implementation works as expected, raising a runtime error:
The easiest way of solving this could be to add a small check at the top of
eval
:I fixed the code in my fork just like this, but I would be happy to open a PR with a different solution if you like.
/Agustín