mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt,parser: prevent unknown module error (#10004)
This commit is contained in:
parent
99a2fd76c8
commit
8c44873674
@ -3,6 +3,7 @@ module module_fmt
|
|||||||
pub struct MyStruct {
|
pub struct MyStruct {
|
||||||
mut:
|
mut:
|
||||||
value int
|
value int
|
||||||
|
foo mod.Foo
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (m MyStruct) foo() bool {
|
pub fn (m MyStruct) foo() bool {
|
||||||
|
@ -342,7 +342,7 @@ pub fn (mut p Parser) parse_any_type(language ast.Language, is_ptr bool, check_d
|
|||||||
p.next()
|
p.next()
|
||||||
p.check(.dot)
|
p.check(.dot)
|
||||||
}
|
}
|
||||||
if !p.known_import(mod) {
|
if !p.known_import(mod) && !p.pref.is_fmt {
|
||||||
mut msg := 'unknown module `$mod`'
|
mut msg := 'unknown module `$mod`'
|
||||||
if mod.len > mod_last_part.len && p.known_import(mod_last_part) {
|
if mod.len > mod_last_part.len && p.known_import(mod_last_part) {
|
||||||
msg += '; did you mean `$mod_last_part`?'
|
msg += '; did you mean `$mod_last_part`?'
|
||||||
@ -352,9 +352,10 @@ pub fn (mut p Parser) parse_any_type(language ast.Language, is_ptr bool, check_d
|
|||||||
}
|
}
|
||||||
if mod in p.imports {
|
if mod in p.imports {
|
||||||
p.register_used_import(mod)
|
p.register_used_import(mod)
|
||||||
|
mod = p.imports[mod]
|
||||||
}
|
}
|
||||||
// prefix with full module
|
// prefix with full module
|
||||||
name = '${p.imports[mod]}.$p.tok.lit'
|
name = '${mod}.$p.tok.lit'
|
||||||
if p.tok.lit.len > 0 && !p.tok.lit[0].is_capital() {
|
if p.tok.lit.len > 0 && !p.tok.lit[0].is_capital() {
|
||||||
p.error('imported types must start with a capital letter')
|
p.error('imported types must start with a capital letter')
|
||||||
return 0
|
return 0
|
||||||
|
Loading…
Reference in New Issue
Block a user