The function `array.reverse` takes an array as an argument, and returns an array with a reversed order of elements.
The function `strings.reverse` takes a string as an argument, and returns a string with a reversed order of unicode code points.
WASM support is included for both built-ins.
Fixes#3736
Signed-off-by: Kristian Svalland <kristian.svalland@gmail.com>
In topdown, we have two different error modes: strict/non-strict.
In WASM, everything is meant to be non-strict. Thus errors that
only appear in topdown with strict mode are annotated as such,
and checked for an empty result-set in the WASM test runner.
Several WASM builtins that have returned an error where they should
return NULL have been adjusted.
This allows us to fix most of the exceptions brought up in #2954.
Notable pieces:
* wasm sdk: ignore builtin errors
This should be in line with the non-strict builtin error semantics used
in WASM.
Before, when the WASM SDK had called out top a topdown-defined builtin,
and that builtin had returned an error, the WASM caller returned that
error. It's been at odds with how topdown evaluated builtin errors when
run without strict builtin errors.
Now, the errors are properly ignored, except for topdown.Halt. That one
doesn't seem like it's used at the moment, at least from this code base.
* cases: add want_result where non-strict eval yields something
This happens to work for both topdown and wasm:
- in topdown, the test runner checks for expected errors first, and
ignores the wanted result;
- in wasm, we check for a desired result first, checking the error
if no result was defined.
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>