fmt: fix if x := g() { x } else { return } adding newline after return (fix #24908) (#24945)

This commit is contained in:
Delyan Angelov 2025-07-22 11:45:59 +03:00 committed by GitHub
parent 5d4e89f888
commit 4205697d88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 4 deletions

View File

@ -1613,7 +1613,9 @@ pub fn (mut f Fmt) return_stmt(node ast.Return) {
}
}
}
f.writeln('')
if !f.single_line_if {
f.writeln('')
}
}
pub fn (mut f Fmt) sql_stmt(node ast.SqlStmt) {

View File

@ -0,0 +1,8 @@
module main
fn g() ?int {
return 123
}
x := if ff := g() { ff } else { return }
println(x)

View File

@ -155,9 +155,7 @@ fn test_go_call_closure() {
fn test_closures_with_ifstmt() {
a := 1
f := fn [a] (x int) int {
if a > x { return 1
} else { return -1
}
if a > x { return 1 } else { return -1 }
}
g := fn [a] () int {
if true {