1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fmt: fix removal of attrs with comments afterwards ()

This commit is contained in:
Lukas Neubert 2021-03-11 21:44:33 +01:00 committed by GitHub
parent f276280d79
commit c40ab0db72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

@ -2,3 +2,8 @@
[tom: 'jerry'] [tom: 'jerry']
[direct_array_access; inline; unsafe] [direct_array_access; inline; unsafe]
fn heavily_tagged() {} 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] [unsafe]
[tom: 'jerry'] [tom: 'jerry']
fn heavily_tagged() {} 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 break
} }
// println('stmt at ' + p.tok.str()) // println('stmt at ' + p.tok.str())
stmts << p.top_stmt() stmt := p.top_stmt()
// clear the attributes after each statement // 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('nr stmts = $stmts.len')
// println(stmts[0]) // println(stmts[0])