1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fmt: fix import alias

This commit is contained in:
Alexander Medvednikov 2020-02-21 20:12:55 +01:00
parent 9be87d03f5
commit 7acf8efde3

View File

@ -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')