checker: prevent `x := voidfn()`

pull/4589/head
Delyan Angelov 2020-04-25 18:06:26 +03:00
parent 6a834c0528
commit 7c080c5d4a
1 changed files with 3 additions and 0 deletions

View File

@ -943,6 +943,9 @@ pub fn (c mut Checker) assign_stmt(assign_stmt mut ast.AssignStmt) {
mut ident_var_info := ident.var_info()
// c.assigned_var_name = ident.name
val_type := c.expr(assign_stmt.right[i])
if val_type == table.void_type {
c.error('expression does not return a value', assign_stmt.right[i].position())
}
if assign_stmt.op == .assign {
var_type := c.expr(ident)
assign_stmt.left_types << var_type