parser: require ++/-- to be on the same line as the previous token (#8621)
							parent
							
								
									367dbc7707
								
							
						
					
					
						commit
						ff1aa06455
					
				| 
						 | 
				
			
			@ -377,6 +377,10 @@ pub fn (mut p Parser) expr_with_left(left ast.Expr, precedence int, is_stmt_iden
 | 
			
		|||
				p.warn_with_pos('`$p.tok.kind` operator can only be used as a statement',
 | 
			
		||||
					p.peek_tok.position())
 | 
			
		||||
			}
 | 
			
		||||
			if p.tok.kind in [.inc, .dec] && p.prev_tok.line_nr != p.tok.line_nr {
 | 
			
		||||
				p.error_with_pos('$p.tok must be on the same line as the previous token',
 | 
			
		||||
					p.tok.position())
 | 
			
		||||
			}
 | 
			
		||||
			node = ast.PostfixExpr{
 | 
			
		||||
				op: p.tok.kind
 | 
			
		||||
				expr: node
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,5 @@
 | 
			
		|||
vlib/v/parser/tests/postfix_inc.vv:3:1: error: `++` must be on the same line as the previous token
 | 
			
		||||
    1 | mut v := 4
 | 
			
		||||
    2 | _ = v
 | 
			
		||||
    3 | ++v
 | 
			
		||||
      | ~~
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,3 @@
 | 
			
		|||
mut v := 4
 | 
			
		||||
_ = v
 | 
			
		||||
++v
 | 
			
		||||
		Loading…
	
		Reference in New Issue