all: remove `var` key
							parent
							
								
									20013e4b4b
								
							
						
					
					
						commit
						9971c58ca3
					
				| 
						 | 
				
			
			@ -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()
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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`
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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`')
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue