From 1c847e04c87ebe5de5011149fa9e2de3610d6881 Mon Sep 17 00:00:00 2001 From: Lukas Neubert Date: Mon, 16 Aug 2021 04:15:32 +0200 Subject: [PATCH] fmt: fix malformed import for incorrect module lookup paths (#11192) --- vlib/v/fmt/fmt.v | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 308de2638f..011ccc22cc 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -286,9 +286,9 @@ pub fn (mut f Fmt) imports(imports []ast.Import) { } pub fn (f Fmt) imp_stmt_str(imp ast.Import) string { - is_diff := imp.alias != imp.mod && !imp.mod.ends_with('.' + imp.alias) + mod := if imp.mod.len == 0 { imp.alias } else { imp.mod } + is_diff := imp.alias != mod && !mod.ends_with('.' + imp.alias) mut imp_alias_suffix := if is_diff { ' as $imp.alias' } else { '' } - mut syms := imp.syms.map(it.name).filter(f.import_syms_used[it]) syms.sort() if syms.len > 0 { @@ -298,7 +298,7 @@ pub fn (f Fmt) imp_stmt_str(imp ast.Import) string { ' {\n\t' + syms.join(',\n\t') + ',\n}' } } - return '$imp.mod$imp_alias_suffix' + return '$mod$imp_alias_suffix' } //=== Node helpers ===//