From dbb64ec14917e93019a6adc1080a6db0e4cdd1f3 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 28 Jul 2019 01:22:15 +0200 Subject: [PATCH] Revert "modules: fix "is not a directory" error" This reverts commit d38940ad576ade8aea17011c033bd0a591394c0b. --- compiler/main.v | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/compiler/main.v b/compiler/main.v index 19758d92ac..4c240a5e36 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -918,7 +918,8 @@ fn (v mut V) add_user_v_files() { } // Parse lib imports if v.pref.build_mode == .default_mode { - for mod in v.table.imports { + for i := 0; i < v.table.imports.len; i++ { + mod := v.table.imports[i] mod_path := v.module_path(mod) import_path := '$ModPath/vlib/$mod_path' vfiles := v.v_files_from_dir(import_path) @@ -934,12 +935,14 @@ fn (v mut V) add_user_v_files() { } } else { - for mod in v.table.imports { + // TODO this used to crash compiler? + // for mod in v.table.imports { + for i := 0; i < v.table.imports.len; i++ { + mod := v.table.imports[i] mod_path := v.module_path(mod) idir := os.getwd() mut import_path := '$idir/$mod_path' - //if !os.file_exists(import_path) || !os.is_dir(import_path){ - if !os.is_dir(import_path){ + if !os.file_exists(import_path) { import_path = '$v.lang_dir/vlib/$mod_path' } vfiles := v.v_files_from_dir(import_path) @@ -977,7 +980,7 @@ fn (v mut V) add_user_v_files() { if v.pref.build_mode == .default_mode || v.pref.build_mode == .build { module_path = '$ModPath/vlib/$mod_p' } - if !os.is_dir(module_path) { + if !os.file_exists(module_path) { module_path = '$v.lang_dir/vlib/$mod_p' } vfiles := v.v_files_from_dir(module_path) @@ -986,6 +989,7 @@ fn (v mut V) add_user_v_files() { v.files << file } } + // TODO v.files.append_array(vfiles) } // add remaining files (not mods) for fit in file_imports {