From dfb6682089ad758b7ba72733778a9aa8c544c164 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 1 Dec 2015 02:29:21 -0700 Subject: add test for bad import --- src/codegen.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index 5ce95023e1..baae91a206 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -669,6 +669,7 @@ static void init(CodeGen *g, Buf *source_path) { } static ImportTableEntry *codegen_add_code(CodeGen *g, Buf *source_path, Buf *source_code) { + int err; Buf full_path = BUF_INIT; os_path_join(g->root_source_dir, source_path, &full_path); @@ -736,7 +737,11 @@ static ImportTableEntry *codegen_add_code(CodeGen *g, Buf *source_path, Buf *sou Buf full_path = BUF_INIT; os_path_join(g->root_source_dir, &top_level_decl->data.use.path, &full_path); Buf *import_code = buf_alloc(); - os_fetch_file_path(&full_path, import_code); + if ((err = os_fetch_file_path(&full_path, import_code))) { + add_node_error(g, top_level_decl, + buf_sprintf("unable to open \"%s\": %s", buf_ptr(&full_path), err_str(err))); + break; + } codegen_add_code(g, &top_level_decl->data.use.path, import_code); } } -- cgit v1.2.3