We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
if x := g() { x } else { return }
return
1 parent 5d4e89f commit 4205697Copy full SHA for 4205697
3 files changed
vlib/v/fmt/fmt.v
@@ -1613,7 +1613,9 @@ pub fn (mut f Fmt) return_stmt(node ast.Return) {
1613
}
1614
1615
1616
- f.writeln('')
+ if !f.single_line_if {
1617
+ f.writeln('')
1618
+ }
1619
1620
1621
pub fn (mut f Fmt) sql_stmt(node ast.SqlStmt) {
vlib/v/fmt/tests/if_ternary_return_keep.vv
@@ -0,0 +1,8 @@
1
+module main
2
+
3
+fn g() ?int {
4
+ return 123
5
+}
6
7
+x := if ff := g() { ff } else { return }
8
+println(x)
vlib/v/tests/fns/closure_test.v
@@ -155,9 +155,7 @@ fn test_go_call_closure() {
155
fn test_closures_with_ifstmt() {
156
a := 1
157
f := fn [a] (x int) int {
158
- if a > x { return 1
159
- } else { return -1
160
- }
+ if a > x { return 1 } else { return -1 }
161
162
g := fn [a] () int {
163
if true {
0 commit comments