Problem
Exn<String> cannot be used as an exception handler type because String is represented as an i32_pair in the WASM ABI, and WASM exception tags only support scalar types (i32, i64, f64, f32).
-- This fails at compile/run time:
handle[Exn<String>] { ... }
Workarounds:
- Use
Exn<Int> or another scalar-typed exception (consistent with ch07_exn_handler.vera)
- Or wrap the string in an ADT before throwing
Root Cause
The WASM exception proposal requires tag parameters to be value types. String in Vera is a fat pointer (i32_pair: pointer + length), which cannot be encoded as a single WASM tag parameter.
Fix
Either:
- Encode
String-typed exceptions as a single heap pointer (i32) in the WASM tag, with the string allocated on the linear memory heap, or
- Automatically box
i32_pair types when used in exception tags
Impact
Users cannot throw/catch string-valued exceptions, which is a common pattern (error messages). This was discovered while writing tests/conformance/ch07_nested_handlers.vera.
Problem
Exn<String>cannot be used as an exception handler type becauseStringis represented as ani32_pairin the WASM ABI, and WASM exception tags only support scalar types (i32,i64,f64,f32).Workarounds:
Exn<Int>or another scalar-typed exception (consistent withch07_exn_handler.vera)Root Cause
The WASM exception proposal requires tag parameters to be value types.
Stringin Vera is a fat pointer (i32_pair: pointer + length), which cannot be encoded as a single WASM tag parameter.Fix
Either:
String-typed exceptions as a single heap pointer (i32) in the WASM tag, with the string allocated on the linear memory heap, ori32_pairtypes when used in exception tagsImpact
Users cannot throw/catch string-valued exceptions, which is a common pattern (error messages). This was discovered while writing
tests/conformance/ch07_nested_handlers.vera.