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

checker/parser: fix outdated error messages

This commit is contained in:
Kris Cherven 2020-04-19 14:46:48 -04:00 committed by GitHub
parent 583b61f883
commit 95ae915c0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -335,7 +335,7 @@ fn (c mut Checker) assign_expr(assign_expr mut ast.AssignExpr) {
scope := c.file.scope.innermost(assign_expr.pos.pos)
if v := scope.find_var(it.name) {
if !v.is_mut {
c.error('`$it.name` is immutable, declare it with `mut`', assign_expr.pos)
c.error('`$it.name` is immutable, declare it with `var` to assign to it', assign_expr.pos)
}
}
}

View File

@ -24,7 +24,7 @@ fn (var p Parser) for_stmt() ast.Stmt {
is_inf: true
}
} else if p.tok.kind in [.key_mut, .key_var] {
p.error('`mut` is not needed in for loops')
p.error('`var` is not needed in for loops')
} else if p.peek_tok.kind in [.decl_assign, .assign, .semicolon] || p.tok.kind == .semicolon {
// `for i := 0; i < 10; i++ {`
var init := ast.Stmt{}