fmt: fix removal of attrs with comments afterwards (#9255)
parent
f276280d79
commit
c40ab0db72
|
@ -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,10 +240,13 @@ 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
|
||||||
|
if !(stmt is ast.ExprStmt && (stmt as ast.ExprStmt).expr is ast.Comment) {
|
||||||
p.attrs = []
|
p.attrs = []
|
||||||
}
|
}
|
||||||
|
stmts << stmt
|
||||||
|
}
|
||||||
// println('nr stmts = $stmts.len')
|
// println('nr stmts = $stmts.len')
|
||||||
// println(stmts[0])
|
// println(stmts[0])
|
||||||
p.scope.end_pos = p.tok.pos
|
p.scope.end_pos = p.tok.pos
|
||||||
|
|
Loading…
Reference in New Issue