checker/parser: fix outdated error messages
parent
583b61f883
commit
95ae915c0c
|
@ -335,7 +335,7 @@ fn (c mut Checker) assign_expr(assign_expr mut ast.AssignExpr) {
|
||||||
scope := c.file.scope.innermost(assign_expr.pos.pos)
|
scope := c.file.scope.innermost(assign_expr.pos.pos)
|
||||||
if v := scope.find_var(it.name) {
|
if v := scope.find_var(it.name) {
|
||||||
if !v.is_mut {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ fn (var p Parser) for_stmt() ast.Stmt {
|
||||||
is_inf: true
|
is_inf: true
|
||||||
}
|
}
|
||||||
} else if p.tok.kind in [.key_mut, .key_var] {
|
} 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 {
|
} else if p.peek_tok.kind in [.decl_assign, .assign, .semicolon] || p.tok.kind == .semicolon {
|
||||||
// `for i := 0; i < 10; i++ {`
|
// `for i := 0; i < 10; i++ {`
|
||||||
var init := ast.Stmt{}
|
var init := ast.Stmt{}
|
||||||
|
|
Loading…
Reference in New Issue