From ba8cdb297780c583d64fd1a8d5f06f8596ac9d35 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 14 Nov 2020 12:24:46 +0200 Subject: [PATCH] vfmt: fix `$for method in App.methods {}` turning to App(methods) --- vlib/v/fmt/fmt.v | 2 +- vlib/v/tests/comptime_for_test.v | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index c42f5437b2..72c29377f1 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -310,7 +310,7 @@ pub fn (mut f Fmt) stmt(node ast.Stmt) { } ast.CompFor { typ := f.no_cur_mod(f.table.type_to_str(it.typ)) - f.writeln('\$for $it.val_var in ${typ}($it.kind.str()) {') + f.writeln('\$for $it.val_var in ${typ}.$it.kind.str() {') f.stmts(it.stmts) f.writeln('}') } diff --git a/vlib/v/tests/comptime_for_test.v b/vlib/v/tests/comptime_for_test.v index dd43e3fc9b..b4d596147f 100644 --- a/vlib/v/tests/comptime_for_test.v +++ b/vlib/v/tests/comptime_for_test.v @@ -31,7 +31,9 @@ fn (mut app App) int_method2() int { fn (mut app App) string_arg(x string) { } -fn no_lines(s string) string { return s.replace('\n', ' ') } +fn no_lines(s string) string { + return s.replace('\n', ' ') +} fn test_comptime_for() { println(@FN) @@ -46,7 +48,7 @@ fn test_comptime_for_with_if() { println(@FN) $for method in App.methods { println(' method: ' + no_lines('$method')) - $if method.typ is fn() { + $if method.typ is fn () { assert method.name in ['run', 'method2'] } $if method.return_type is int {