From 1c7fb65491ea7c38ee46a449e3d0a2473b319970 Mon Sep 17 00:00:00 2001 From: Gaetano <64538010+skrtdev@users.noreply.github.com> Date: Sat, 17 Apr 2021 07:30:03 +0200 Subject: [PATCH] builder: fix a bug that happens with local modules (#9701) --- vlib/v/builder/builder.v | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/vlib/v/builder/builder.v b/vlib/v/builder/builder.v index 6591a02868..9a40401486 100644 --- a/vlib/v/builder/builder.v +++ b/vlib/v/builder/builder.v @@ -116,9 +116,13 @@ pub fn (mut b Builder) parse_imports() { // Add all imports referenced by these libs parsed_files := parser.parse_files(v_files, b.table, b.pref, b.global_scope) 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 - 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) } }