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

compiler: detect typos in function/variable/module names

This commit is contained in:
joe-conigliaro
2019-09-13 21:10:24 +10:00
committed by Alexander Medvednikov
parent 5055ac4b23
commit 41734affb3
4 changed files with 147 additions and 0 deletions

View File

@@ -1648,6 +1648,11 @@ fn (p mut Parser) name_expr() string {
f = p.table.find_fn(name)
}
if f.name == '' {
// check for misspelled function / variable / module
suggested := p.table.identify_typo(name, p.cur_fn, p.import_table)
if suggested != '' {
p.error('undefined: `$name`. did you mean:$suggested')
}
// If orig_name is a mod, then printing undefined: `mod` tells us nothing
// if p.table.known_mod(orig_name) {
if p.table.known_mod(orig_name) || p.import_table.known_alias(orig_name) {