From 66ffa764dd32b15a9314a555e8f3bf7775736e7a Mon Sep 17 00:00:00 2001 From: joe-conigliaro Date: Thu, 8 Aug 2019 22:35:53 +1000 Subject: [PATCH] compiler: properly add submodule to types --- compiler/parser.v | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/compiler/parser.v b/compiler/parser.v index 402817bb3b..1e69e29ef0 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -923,6 +923,13 @@ fn (p mut Parser) get_type() string { else { // Module specified? (e.g. gx.Image) 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.check(.dot) typ += '__$p.lit' @@ -931,15 +938,6 @@ fn (p mut Parser) get_type() string { // "typ" not found? try "mod__typ" if t.name == '' && !p.builtin_mod { // && !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('__') && !typ.starts_with('[') { typ = p.prepend_mod(typ)