| author | |
| committer | |
| log | c40448eb9a0e777c98c78d4ac0ddf08867618ea4 |
| tree | b12dc5540ebf3d8f92ebdc2e8c3167164f0b2544 |
| parent | 4a5cd0b895d0c6093fa710ed4ecb819726b58c25 |
| signature |
closes #15572 files changed, 14 insertions(+), 0 deletions(-)
src/analyze.cpp+7| ... | @@ -4367,6 +4367,13 @@ static void add_symbols_from_import(CodeGen *g, AstNode *src_use_node, AstNode * | ... | @@ -4367,6 +4367,13 @@ static void add_symbols_from_import(CodeGen *g, AstNode *src_use_node, AstNode * |
| 4367 | ZigType *target_import = use_target_value->data.x_type; | 4367 | ZigType *target_import = use_target_value->data.x_type; |
| 4368 | assert(target_import); | 4368 | assert(target_import); |
| 4369 | 4369 | ||
| 4370 | if (target_import->id != ZigTypeIdStruct) { | ||
| 4371 | add_node_error(g, dst_use_node, | ||
| 4372 | buf_sprintf("expected struct, found '%s'", buf_ptr(&target_import->name))); | ||
| 4373 | get_container_scope(dst_use_node->owner)->any_imports_failed = true; | ||
| 4374 | return; | ||
| 4375 | } | ||
| 4376 | |||
| 4370 | if (get_container_scope(target_import)->any_imports_failed) { | 4377 | if (get_container_scope(target_import)->any_imports_failed) { |
| 4371 | get_container_scope(dst_use_node->owner)->any_imports_failed = true; | 4378 | get_container_scope(dst_use_node->owner)->any_imports_failed = true; |
| 4372 | } | 4379 | } |
test/compile_errors.zig+7| ... | @@ -2,6 +2,13 @@ const tests = @import("tests.zig"); | ... | @@ -2,6 +2,13 @@ const tests = @import("tests.zig"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | 3 | ||
| 4 | pub fn addCases(cases: *tests.CompileErrorContext) void { | 4 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5 | cases.add( | ||
| 6 | "usingnamespace with wrong type", | ||
| 7 | \\use void; | ||
| 8 | , | ||
| 9 | "tmp.zig:1:1: error: expected struct, found 'void'", | ||
| 10 | ); | ||
| 11 | |||
| 5 | cases.add( | 12 | cases.add( |
| 6 | "ignored expression in while continuation", | 13 | "ignored expression in while continuation", |
| 7 | \\export fn a() void { | 14 | \\export fn a() void { |