From 03f774fda9fb23edac878edc9317ebb5652c8857 Mon Sep 17 00:00:00 2001 From: Alexandros Naskos Date: Thu, 21 May 2020 15:06:16 +0300 Subject: [PATCH] Try expression support --- src/analysis.zig | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/analysis.zig b/src/analysis.zig index 10bc4f0..2a8c3df 100644 --- a/src/analysis.zig +++ b/src/analysis.zig @@ -345,6 +345,17 @@ pub fn resolveTypeOfNode(analysis_ctx: *AnalysisContext, node: *ast.Node) ?*ast. else => unreachable, } }, + .Try => { + const rhs_type = resolveTypeOfNode(analysis_ctx, prefix_op.rhs) orelse return null; + switch (rhs_type.id) { + .InfixOp => { + const infix_op = rhs_type.cast(ast.Node.InfixOp).?; + if (infix_op.op == .ErrorUnion) return infix_op.rhs; + }, + else => {}, + } + return rhs_type; + }, else => {}, } },