Implement rudimentary type inference for unary operators

This commit is contained in:
Marcus Klaas de Vries 2019-01-14 23:15:16 +01:00
parent ab46f8abf1
commit a2b6d3da30
4 changed files with 72 additions and 5 deletions

View file

@ -182,7 +182,7 @@ pub enum Expr {
},
UnaryOp {
expr: ExprId,
op: Option<UnaryOp>,
op: UnaryOp,
},
BinaryOp {
lhs: ExprId,
@ -612,8 +612,11 @@ impl ExprCollector {
}
ast::ExprKind::PrefixExpr(e) => {
let expr = self.collect_expr_opt(e.expr());
let op = e.op();
self.alloc_expr(Expr::UnaryOp { expr, op }, syntax_ptr)
if let Some(op) = e.op() {
self.alloc_expr(Expr::UnaryOp { expr, op }, syntax_ptr)
} else {
self.alloc_expr(Expr::Missing, syntax_ptr)
}
}
ast::ExprKind::LambdaExpr(e) => {
let mut args = Vec::new();