Merge pull request #70 from alexnask/try_expr

Try expression support
This commit is contained in:
Auguste Rame 2020-05-21 09:14:10 -04:00 committed by GitHub
commit 3169202d88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 => {},
}
},