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

compiler: properly add submodule to types

This commit is contained in:
joe-conigliaro 2019-08-08 22:35:53 +10:00 committed by Alexander Medvednikov
parent b8d37e0d53
commit 66ffa764dd

View File

@ -923,6 +923,13 @@ fn (p mut Parser) get_type() string {
else { else {
// Module specified? (e.g. gx.Image) // Module specified? (e.g. gx.Image)
if p.peek() == .dot { if p.peek() == .dot {
// try resolve full submodule
if !p.builtin_mod && p.import_table.known_alias(typ) {
mod := p.import_table.resolve_alias(typ)
if mod.contains('.') {
typ = mod.replace('.', '_dot_')
}
}
p.next() p.next()
p.check(.dot) p.check(.dot)
typ += '__$p.lit' typ += '__$p.lit'
@ -931,15 +938,6 @@ fn (p mut Parser) get_type() string {
// "typ" not found? try "mod__typ" // "typ" not found? try "mod__typ"
if t.name == '' && !p.builtin_mod { if t.name == '' && !p.builtin_mod {
// && !p.first_pass() { // && !p.first_pass() {
// we are a module
if typ.contains('__') {
// so try resolve full submodule
mod := p.import_table.resolve_alias(p.lit).replace('.', '_dot_')
if mod != '' {
typ = prepend_mod(mod, typ)
}
}
t = p.table.find_type(typ)
if !typ.contains('array_') && p.mod != 'main' && !typ.contains('__') && if !typ.contains('array_') && p.mod != 'main' && !typ.contains('__') &&
!typ.starts_with('[') { !typ.starts_with('[') {
typ = p.prepend_mod(typ) typ = p.prepend_mod(typ)