From 7acf8efde3949b08cfa3070e482cdd95e18a8d56 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 21 Feb 2020 20:12:55 +0100 Subject: [PATCH] fmt: fix import alias --- vlib/v/fmt/fmt.v | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 351ff603fb..842004d6f6 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -84,7 +84,8 @@ fn (f mut Fmt) imports(imports []ast.Import) { } fn (f Fmt) imp_stmt_str(imp ast.Import) string { - imp_alias_suffix := if imp.alias != imp.mod { ' as ${imp.alias}' } else { '' } + is_diff := imp.alias != imp.mod && !imp.mod.ends_with('.' + imp.alias) + imp_alias_suffix := if is_diff { ' as ${imp.alias}' } else { '' } return '${imp.mod}${imp_alias_suffix}' } @@ -127,6 +128,7 @@ fn (f mut Fmt) stmt(node ast.Stmt) { for i, field in it.fields { f.write('$field.name = ') f.expr(it.exprs[i]) + f.writeln('') } f.indent-- f.writeln('\n)\n')