diff --git a/compiler/lib/wasm/wa_wat_output.ml b/compiler/lib/wasm/wa_wat_output.ml index f4dc9b55..1d6016dc 100644 --- a/compiler/lib/wasm/wa_wat_output.ml +++ b/compiler/lib/wasm/wa_wat_output.ml @@ -478,16 +478,13 @@ let expression_or_instructions ctx st in_function = ] | Try (ty, body, catches) -> [ List - (Atom "try" + (Atom "try_table" :: (block_type st ty - @ List (Atom "do" :: instructions body) - :: List.map - ~f:(fun (tag, i, ty) -> - List - (Atom "catch" - :: index st.tag_names tag - :: instruction (Wa_ast.Br (i + 1, Some (Pop ty))))) - catches)) + @ List.map + ~f:(fun (tag, i, _ty) -> + List [ Atom "catch"; index st.tag_names tag; Atom (string_of_int i) ]) + catches + @ instructions body)) ] and instruction i = match i with