builder: fix a bug that happens with local modules (#9701)

pull/9777/head
Gaetano 2021-04-17 07:30:03 +02:00 committed by GitHub
parent 731e942055
commit 1c7fb65491
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -116,9 +116,13 @@ pub fn (mut b Builder) parse_imports() {
// Add all imports referenced by these libs // Add all imports referenced by these libs
parsed_files := parser.parse_files(v_files, b.table, b.pref, b.global_scope) parsed_files := parser.parse_files(v_files, b.table, b.pref, b.global_scope)
for file in parsed_files { for file in parsed_files {
if file.mod.name != mod { mut name := file.mod.name
if name == '' {
name = file.mod.short_name
}
if name != mod {
// v.parsers[pidx].error_with_token_index('bad module definition: ${v.parsers[pidx].file_path} imports module "$mod" but $file is defined as module `$p_mod`', 1 // v.parsers[pidx].error_with_token_index('bad module definition: ${v.parsers[pidx].file_path} imports module "$mod" but $file is defined as module `$p_mod`', 1
error_with_pos('bad module definition: $ast_file.path imports module "$mod" but $file.path is defined as module `$file.mod.name`', error_with_pos('bad module definition: $ast_file.path imports module "$mod" but $file.path is defined as module `$name`',
ast_file.path, imp.pos) ast_file.path, imp.pos)
} }
} }