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

@@ -1018,21 +1018,17 @@ fn (f &Fn) str_args(table &Table) string {
}
// find local function variable with closest name to `name`
fn (f &Fn) find_misspelled_local_var(name string, min_match f64) string {
mut closest := f64(0)
fn (f &Fn) find_misspelled_local_var(name string, min_match f32) string {
mut closest := f32(0)
mut closest_var := ''
for var in f.local_vars {
n := '${f.mod}.$var.name'
if var.name == '' || !name.starts_with(f.mod) || (n.len - name.len > 3 || name.len - n.len > 3) { continue }
p := strings.dice_coefficient(name, n)
println(' ## $name - $n: $p')
if p > closest {
closest = p
closest_var = n
}
}
if closest >= min_match {
return closest_var
}
return ''
return if closest >= min_match { closest_var } else { '' }
}