diff --git a/include/wabt/decompiler-ast.h b/include/wabt/decompiler-ast.h index 33cc26c11..a2d184d1d 100644 --- a/include/wabt/decompiler-ast.h +++ b/include/wabt/decompiler-ast.h @@ -217,8 +217,12 @@ struct AST { return; } case ExprType::Br: { - InsertNode(NodeType::Expr, ExprType::Br, &e, 0).u.lt = - mc.GetLabel(cast(&e)->var)->label_type; + LabelType lt = mc.GetLabel(cast(&e)->var)->label_type; + if (lt == LabelType::Func) { + InsertNode(NodeType::Expr, ExprType::Return, &e, arity.nargs); + return; + } + InsertNode(NodeType::Expr, ExprType::Br, &e, 0).u.lt = lt; return; } case ExprType::BrIf: { diff --git a/test/decompile/br_return.txt b/test/decompile/br_return.txt new file mode 100644 index 000000000..499cdeba1 --- /dev/null +++ b/test/decompile/br_return.txt @@ -0,0 +1,12 @@ +;;; TOOL: run-wasm-decompile + +(module + (func $f (result i32) i32.const 10 br 0) +) + +(;; STDOUT ;;; +function f_a():int { + return 10 +} + +;;; STDOUT ;;)