fmt: fix malformed import for incorrect module lookup paths (#11192)

pull/11200/head
Lukas Neubert 2021-08-16 04:15:32 +02:00 committed by GitHub
parent 60f21f065f
commit 1c847e04c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -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 ===//