commit d5a5d2e1f205aaa313f2d74bb43279be935e80f2 parent ca6549e62bafd818aeb242c7b85e97344769185d Author: Alexey Yerin <yyp@disroot.org> Date: Sun, 22 Aug 2021 21:38:38 +0300 hare::unit: use match insead of mutating body Signed-off-by: Alexey Yerin <yyp@disroot.org> Diffstat:
M | hare/unit/process.ha | | | 8 | +++----- |
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/hare/unit/process.ha b/hare/unit/process.ha @@ -48,11 +48,9 @@ fn process_func( assert(fntype.variadism == types::variadism::NONE); // TODO assert(len(fntype.params) == 0); // TODO - let body: nullable *expr = null; - // TODO: Change the afndecl body field to nullable *ast::expr - if (afndecl.body is ast::expr) { - const abody = afndecl.body as ast::expr; - body = process_expr(ctx, &abody)?; + const body: nullable *expr = match (afndecl.body) { + abody: ast::expr => process_expr(ctx, &abody)?, + void => null, }; return decl {