@@ -1712,27 +1712,29 @@ private class WasmExpressionBuilder private (
17121712 genTree(t.block, t.tpe)
17131713 instrs += CATCH (ctx.exceptionTagName)
17141714 fctx.withNewLocal(t.errVar.name, Types .WasmRefType .anyref) { exceptionLocal =>
1715+ instrs += ANY_CONVERT_EXTERN
17151716 instrs += LOCAL_SET (exceptionLocal)
17161717 genTree(t.handler, t.tpe)
17171718 }
17181719 instrs += END
17191720 } else {
17201721 fctx.block(resultType) { doneLabel =>
1721- fctx.block(Types .WasmRefType .anyref ) { catchLabel =>
1722- /* We used to have `resultType` as result of the try_table, wich the
1722+ fctx.block(Types .WasmRefType .externref ) { catchLabel =>
1723+ /* We used to have `resultType` as result of the try_table, with the
17231724 * `BR(doneLabel)` outside of the try_table. Unfortunately it seems
17241725 * V8 cannot handle try_table with a result type that is `(ref ...)`.
1725- * The current encoding with `anyref ` as result type (to match the
1726+ * The current encoding with `externref ` as result type (to match the
17261727 * enclosing block) and the `br` *inside* the `try_table` works.
17271728 */
1728- fctx.tryTable(Types .WasmRefType .anyref )(
1729+ fctx.tryTable(Types .WasmRefType .externref )(
17291730 List (CatchClause .Catch (ctx.exceptionTagName, catchLabel))
17301731 ) {
17311732 genTree(t.block, t.tpe)
17321733 instrs += BR (doneLabel)
17331734 }
17341735 } // end block $catch
17351736 fctx.withNewLocal(t.errVar.name, Types .WasmRefType .anyref) { exceptionLocal =>
1737+ instrs += ANY_CONVERT_EXTERN
17361738 instrs += LOCAL_SET (exceptionLocal)
17371739 genTree(t.handler, t.tpe)
17381740 }
@@ -1790,6 +1792,7 @@ private class WasmExpressionBuilder private (
17901792
17911793 private def genThrow (tree : IRTrees .Throw ): IRTypes .Type = {
17921794 genTree(tree.expr, IRTypes .AnyType )
1795+ instrs += EXTERN_CONVERT_ANY
17931796 instrs += THROW (ctx.exceptionTagName)
17941797
17951798 IRTypes .NothingType
0 commit comments