1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: prevent x := voidfn()

This commit is contained in:
Delyan Angelov 2020-04-25 18:06:26 +03:00
parent 6a834c0528
commit 7c080c5d4a

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