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

typo detection: only check fn variables in same or higher scope

This commit is contained in:
joe-conigliaro 2019-09-20 19:23:43 +10:00 committed by Alexander Medvednikov
parent ba4ea351c7
commit f657d70a67

View File

@ -1057,6 +1057,9 @@ fn (f &Fn) find_misspelled_local_var(name string, min_match f32) string {
mut closest := f32(0) mut closest := f32(0)
mut closest_var := '' mut closest_var := ''
for var in f.local_vars { for var in f.local_vars {
if var.scope_level > f.scope_level {
continue
}
n := name.all_after('.') n := name.all_after('.')
if var.name == '' || (n.len - var.name.len > 2 || var.name.len - n.len > 2) { continue } if var.name == '' || (n.len - var.name.len > 2 || var.name.len - n.len > 2) { continue }
p := strings.dice_coefficient(var.name, n) p := strings.dice_coefficient(var.name, n)