diff --git a/vlib/v/parser/assign.v b/vlib/v/parser/assign.v index 33c2f53a6f..7264a4512b 100644 --- a/vlib/v/parser/assign.v +++ b/vlib/v/parser/assign.v @@ -77,7 +77,7 @@ pub fn (mut p Parser) assign_expr(left ast.Expr) ast.AssignExpr { fn (mut p Parser) parse_assign_lhs() []ast.Ident { mut idents := []ast.Ident{} for { - is_mut := p.tok.kind == .key_mut || p.tok.kind == .key_var + is_mut := p.tok.kind == .key_mut if is_mut { p.next() } diff --git a/vlib/v/parser/fn.v b/vlib/v/parser/fn.v index 787c2446ad..1b759f8f2f 100644 --- a/vlib/v/parser/fn.v +++ b/vlib/v/parser/fn.v @@ -110,7 +110,7 @@ fn (mut p Parser) fn_decl() ast.FnDecl { if p.tok.kind == .lpar { p.next() // ( is_method = true - rec_mut = p.tok.kind in [.key_var, .key_mut] + rec_mut = p.tok.kind == .key_mut if rec_mut { p.next() // `mut` } diff --git a/vlib/v/parser/for.v b/vlib/v/parser/for.v index 8842f372ba..e7f9b99a8d 100644 --- a/vlib/v/parser/for.v +++ b/vlib/v/parser/for.v @@ -23,8 +23,8 @@ fn (mut p Parser) for_stmt() ast.Stmt { pos: pos is_inf: true } - } else if p.tok.kind in [.key_mut, .key_var] { - p.error('`var` is not needed in for loops') + } else if p.tok.kind == .key_mut { + p.error('`mut` 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++ {` mut init := ast.Stmt{} @@ -76,7 +76,6 @@ fn (mut p Parser) for_stmt() ast.Stmt { val_var_pos = p.tok.position() key_var_name = val_var_name val_var_name = p.check_name() - if p.scope.known_var(key_var_name) { p.error('redefinition of key iteration variable `$key_var_name`') } diff --git a/vlib/v/parser/if.v b/vlib/v/parser/if.v index 900b713e12..bfe7f8993f 100644 --- a/vlib/v/parser/if.v +++ b/vlib/v/parser/if.v @@ -86,7 +86,7 @@ fn (mut p Parser) match_expr() ast.MatchExpr { match_first_pos := p.tok.position() p.inside_match = true p.check(.key_match) - is_mut := p.tok.kind in [.key_mut, .key_var] + is_mut := p.tok.kind == .key_mut mut is_sum_type := false if is_mut { p.next() @@ -106,8 +106,9 @@ fn (mut p Parser) match_expr() ast.MatchExpr { if p.tok.kind == .key_else { is_else = true p.next() - } else if p.tok.kind == .name && !(p.tok.lit == 'C' && p.peek_tok.kind == .dot) && (p.tok.lit in table.builtin_type_names || (p.tok.lit[0].is_capital() && - !p.tok.lit.is_upper()) || p.peek_tok.kind == .dot) { + } else if p.tok.kind == .name && !(p.tok.lit == 'C' && p.peek_tok.kind == .dot) && + (p.tok.lit in table.builtin_type_names || (p.tok.lit[0].is_capital() && !p.tok.lit.is_upper()) || + p.peek_tok.kind == .dot) { // Sum type match typ := p.parse_type() exprs << ast.Type{ diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 3054d2a713..e5e02645cc 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -398,7 +398,7 @@ pub fn (mut p Parser) stmt() ast.Stmt { pos: assert_pos } } - .key_mut, .key_static, .key_var { + .key_mut, .key_static { return p.assign_stmt() } .key_for { diff --git a/vlib/v/token/token.v b/vlib/v/token/token.v index f688064bfc..9db2e4b850 100644 --- a/vlib/v/token/token.v +++ b/vlib/v/token/token.v @@ -120,7 +120,6 @@ pub enum Kind { key_pub key_static key_unsafe - key_var keyword_end _end_ } @@ -246,7 +245,6 @@ fn build_token_str() []string { s[Kind.key_none] = 'none' s[Kind.key_offsetof] = '__offsetof' s[Kind.key_is] = 'is' - s[Kind.key_var] = 'var' return s }