From 70b76a8e312682011b856d8f1b4c5135a5b33972 Mon Sep 17 00:00:00 2001 From: yuyi Date: Thu, 14 May 2020 15:59:29 +0800 Subject: [PATCH] builder: use verror for not found modules --- vlib/v/builder/builder.v | 5 +++-- vlib/v/checker/tests/import_not_found_err.out | 1 + vlib/v/checker/tests/import_not_found_err.vv | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 vlib/v/checker/tests/import_not_found_err.out create mode 100644 vlib/v/checker/tests/import_not_found_err.vv diff --git a/vlib/v/builder/builder.v b/vlib/v/builder/builder.v index c3d457642a..8dc3ba366d 100644 --- a/vlib/v/builder/builder.v +++ b/vlib/v/builder/builder.v @@ -67,12 +67,13 @@ pub fn (mut b Builder) parse_imports() { // break // println('module_search_paths:') // println(b.module_search_paths) - panic('cannot import module "$mod" (not found)') + verror('cannot import module "$mod" (not found)') + break } v_files := b.v_files_from_dir(import_path) if v_files.len == 0 { // v.parsers[i].error_with_token_index('cannot import module "$mod" (no .v files in "$import_path")', v.parsers[i].import_table.get_import_tok_idx(mod)) - panic('cannot import module "$mod" (no .v files in "$import_path")') + verror('cannot import module "$mod" (no .v files in "$import_path")') } // Add all imports referenced by these libs parsed_files := parser.parse_files(v_files, b.table, b.pref, b.global_scope) diff --git a/vlib/v/checker/tests/import_not_found_err.out b/vlib/v/checker/tests/import_not_found_err.out new file mode 100644 index 0000000000..cee9ed2971 --- /dev/null +++ b/vlib/v/checker/tests/import_not_found_err.out @@ -0,0 +1 @@ +builder error: cannot import module "notexist" (not found) diff --git a/vlib/v/checker/tests/import_not_found_err.vv b/vlib/v/checker/tests/import_not_found_err.vv new file mode 100644 index 0000000000..fa7ae37441 --- /dev/null +++ b/vlib/v/checker/tests/import_not_found_err.vv @@ -0,0 +1,4 @@ +import notexist +fn main() { + println('hello, world') +}