mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vfmt: fix error with return // comment
(#6914)
This commit is contained in:
parent
51c737669d
commit
2f9b7fe0f7
@ -1,6 +1,6 @@
|
||||
fn fun() int {
|
||||
// comment zero
|
||||
return 0
|
||||
return 0 // another comment
|
||||
}
|
||||
|
||||
fn mr_fun() (int, int) {
|
||||
@ -34,4 +34,6 @@ fn main() {
|
||||
else {
|
||||
println('else')
|
||||
}
|
||||
// empty return
|
||||
return
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
fn fun() int {
|
||||
return /* comment zero */ 0
|
||||
return /* comment zero */ 0 // another comment
|
||||
}
|
||||
|
||||
fn mr_fun() (int, int) {
|
||||
@ -22,4 +22,5 @@ fn main() {
|
||||
else /* after else */ {
|
||||
println('else')
|
||||
}
|
||||
return // empty return
|
||||
}
|
||||
|
@ -1737,13 +1737,16 @@ fn (mut p Parser) return_stmt() ast.Return {
|
||||
first_pos := p.tok.position()
|
||||
p.next()
|
||||
// no return
|
||||
mut comments := p.eat_comments()
|
||||
if p.tok.kind == .rcbr {
|
||||
return ast.Return{
|
||||
comments: comments
|
||||
pos: first_pos
|
||||
}
|
||||
}
|
||||
// return exprs
|
||||
exprs, comments := p.expr_list()
|
||||
exprs, comments2 := p.expr_list()
|
||||
comments << comments2
|
||||
end_pos := exprs.last().position()
|
||||
return ast.Return{
|
||||
exprs: exprs
|
||||
|
Loading…
Reference in New Issue
Block a user