wasefire icon indicating copy to clipboard operation
wasefire copied to clipboard

Improve interpreter error messages

Open ia0 opened this issue 2 years ago • 0 comments
trafficstars

Currently, the interpreter just returns a field-less enum (essentially: invalid, not found, unsupported, and trap). This is not useful to understand what's wrong. It's possible to use the debug feature to get a backtrace, but that's also not ideal for debugging if not familiar with the interpreter.

The interpreter should provide a feature (or reuse debug) to return more descriptive error messages. For example:

  • While linking module foo, the import bar::baz could not be found because bar is not an instance.
  • While linking module foo, the import bar::baz could not be found because bar does not contain baz.
  • While linking module foo, the import bar::baz could not be found types differ: expected function, got memory.
  • While executing exported function bar::baz, an unreachable instruction was reached with the following stack trace: ...
  • The wrong number of arguments was provided to invoke exported function bar::baz: expect [i32,f64], got [u32,u64].
  • When an invalid opcode is parsed, the opcode should be returned.

The scheduler should also provide a debug feature (set from the runner from the feature of the same name).

ia0 avatar Mar 22 '23 15:03 ia0