mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
add test for undeclared identifier error
This commit is contained in:
parent
370de7386c
commit
e94681b961
@ -821,7 +821,7 @@ static ImportTableEntry *codegen_add_code(CodeGen *g, Buf *source_path, Buf *sou
|
|||||||
Buf *import_code = buf_alloc();
|
Buf *import_code = buf_alloc();
|
||||||
if ((err = 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,
|
add_node_error(g, top_level_decl,
|
||||||
buf_sprintf("unable to open \"%s\": %s", buf_ptr(&full_path), err_str(err)));
|
buf_sprintf("unable to open '%s': %s", buf_ptr(&full_path), err_str(err)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
codegen_add_code(g, &top_level_decl->data.use.path, import_code);
|
codegen_add_code(g, &top_level_decl->data.use.path, import_code);
|
||||||
|
|||||||
@ -295,7 +295,16 @@ export executable "test";
|
|||||||
|
|
||||||
add_compile_fail_case("bad import", R"SOURCE(
|
add_compile_fail_case("bad import", R"SOURCE(
|
||||||
use "bogus-does-not-exist.zig";
|
use "bogus-does-not-exist.zig";
|
||||||
)SOURCE", 1, ".tmp_source.zig:2:1: error: unable to open \"./bogus-does-not-exist.zig\": file not found");
|
)SOURCE", 1, ".tmp_source.zig:2:1: error: unable to open './bogus-does-not-exist.zig': file not found");
|
||||||
|
|
||||||
|
add_compile_fail_case("undeclared identifier", R"SOURCE(
|
||||||
|
fn a() {
|
||||||
|
b +
|
||||||
|
c
|
||||||
|
}
|
||||||
|
)SOURCE", 2,
|
||||||
|
".tmp_source.zig:3:5: error: use of undeclared identifier 'b'",
|
||||||
|
".tmp_source.zig:4:5: error: use of undeclared identifier 'c'");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_compiler_invokation(TestCase *test_case, Buf *zig_stderr) {
|
static void print_compiler_invokation(TestCase *test_case, Buf *zig_stderr) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user