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:
committed by
Alexander Medvednikov
parent
5055ac4b23
commit
41734affb3
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user