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

compiler: clean up the typo check

This commit is contained in:
joe-conigliaro
2019-09-13 23:15:30 +10:00
committed by Alexander Medvednikov
parent 9dd86f6fb8
commit 5aaa794519
3 changed files with 13 additions and 23 deletions

View File

@ -955,8 +955,8 @@ fn (table &Table) identify_typo(name string, current_fn &Fn, fit &FileImportTabl
}
// find function with closest name to `name`
fn (table &Table) find_misspelled_fn(name string, min_match f64) string {
mut closest := f64(0)
fn (table &Table) find_misspelled_fn(name string, min_match f32) string {
mut closest := f32(0)
mut closest_fn := ''
for _, f in table.fns {
n := '${f.mod}.$f.name'
@ -967,15 +967,12 @@ fn (table &Table) find_misspelled_fn(name string, min_match f64) string {
closest_fn = n
}
}
if closest >= min_match {
return closest_fn
}
return ''
return if closest >= min_match { closest_fn } else { '' }
}
// find imported module with closest name to `name`
fn (table &Table) find_misspelled_imported_mod(name string, fit &FileImportTable, min_match f64) string {
mut closest := f64(0)
fn (table &Table) find_misspelled_imported_mod(name string, fit &FileImportTable, min_match f32) string {
mut closest := f32(0)
mut closest_mod := ''
for alias, mod in fit.imports {
n := '${fit.module_name}.$alias'
@ -986,8 +983,5 @@ fn (table &Table) find_misspelled_imported_mod(name string, fit &FileImportTable
closest_mod = '$alias ($mod)'
}
}
if closest >= min_match {
return closest_mod
}
return ''
return if closest >= min_match { closest_mod } else { '' }
}