From 090ca27b15ffaf8378c6ff8f44fe3537b529d48a Mon Sep 17 00:00:00 2001 From: joe-conigliaro Date: Mon, 23 Sep 2019 20:40:18 +1000 Subject: [PATCH] compiler: improve module typo error message --- compiler/table.v | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/table.v b/compiler/table.v index 992819f9f7..9dfb63f89f 100644 --- a/compiler/table.v +++ b/compiler/table.v @@ -950,10 +950,11 @@ fn (table &Table) find_misspelled_imported_mod(name string, fit &FileImportTable n1 := if name.starts_with('main.') { name.right(5) } else { name } for alias, mod in fit.imports { if (n1.len - alias.len > 2 || alias.len - n1.len > 2) { continue } + mod_alias := if alias == mod { alias } else { '$alias ($mod)' } p := strings.dice_coefficient(n1, alias) if p > closest { closest = p - closest_mod = '$alias ($mod)' + closest_mod = '$mod_alias' } } return if closest >= min_match { closest_mod } else { '' }