fmt: fix removal of attrs with comments afterwards (#9255)
							parent
							
								
									f276280d79
								
							
						
					
					
						commit
						c40ab0db72
					
				|  | @ -2,3 +2,8 @@ | |||
| [tom: 'jerry'] | ||||
| [direct_array_access; inline; unsafe] | ||||
| fn heavily_tagged() {} | ||||
| 
 | ||||
| // console attribute for easier diagnostics on windows
 | ||||
| // also it's not safe to use
 | ||||
| [console; unsafe] | ||||
| fn dangerous_console() {} | ||||
|  |  | |||
|  | @ -4,3 +4,7 @@ | |||
| [unsafe] | ||||
| [tom: 'jerry'] | ||||
| fn heavily_tagged() {} | ||||
| 
 | ||||
| [console] // console attribute for easier diagnostics on windows
 | ||||
| [unsafe] // also it's not safe to use
 | ||||
| fn dangerous_console() {} | ||||
|  |  | |||
|  | @ -240,9 +240,12 @@ pub fn (mut p Parser) parse() ast.File { | |||
| 			break | ||||
| 		} | ||||
| 		// println('stmt at ' + p.tok.str())
 | ||||
| 		stmts << p.top_stmt() | ||||
| 		stmt := p.top_stmt() | ||||
| 		// clear the attributes after each statement
 | ||||
| 		p.attrs = [] | ||||
| 		if !(stmt is ast.ExprStmt && (stmt as ast.ExprStmt).expr is ast.Comment) { | ||||
| 			p.attrs = [] | ||||
| 		} | ||||
| 		stmts << stmt | ||||
| 	} | ||||
| 	// println('nr stmts = $stmts.len')
 | ||||
| 	// println(stmts[0])
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue