From cf441091f197a6893f5caec0d78ee4a81588853b Mon Sep 17 00:00:00 2001 From: Lukas Neubert Date: Mon, 28 Dec 2020 19:27:27 +0100 Subject: [PATCH] fmt: AnonFn with body is not single line (#7659) --- vlib/v/fmt/fmt.v | 5 +++++ vlib/v/fmt/tests/fn_trailing_arg_syntax_keep.vv | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index aeebdbfd3c..6b147ffa58 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -1723,6 +1723,11 @@ fn stmt_is_single_line(stmt ast.Stmt) bool { fn expr_is_single_line(expr ast.Expr) bool { match expr { + ast.AnonFn { + if !expr.decl.no_body { + return false + } + } ast.IfExpr { return false } diff --git a/vlib/v/fmt/tests/fn_trailing_arg_syntax_keep.vv b/vlib/v/fmt/tests/fn_trailing_arg_syntax_keep.vv index 5df0249dcd..cf0f3a08c1 100644 --- a/vlib/v/fmt/tests/fn_trailing_arg_syntax_keep.vv +++ b/vlib/v/fmt/tests/fn_trailing_arg_syntax_keep.vv @@ -35,6 +35,12 @@ fn main() { f: 'here' } ) + ui.button( + width: 70 + onclick: fn (a voidptr, b voidptr) { + webview.new_window(url: 'https://vlang.io', title: 'The V programming language') + } + ) } fn bar_func(bar Bar) {