aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-03-16 00:18:10 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-03-16 00:18:10 -0400
commitc40448eb9a0e777c98c78d4ac0ddf08867618ea4 (patch)
treeb12dc5540ebf3d8f92ebdc2e8c3167164f0b2544 /src/analyze.cpp
parent4a5cd0b895d0c6093fa710ed4ecb819726b58c25 (diff)
downloadzig-c40448eb9a0e777c98c78d4ac0ddf08867618ea4.tar.gz
zig-c40448eb9a0e777c98c78d4ac0ddf08867618ea4.zip
add compile error for wrong type with `use`
closes #1557
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 0a04a14e3f..cadb5dfc01 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -4367,6 +4367,13 @@ static void add_symbols_from_import(CodeGen *g, AstNode *src_use_node, AstNode *
ZigType *target_import = use_target_value->data.x_type;
assert(target_import);
+ if (target_import->id != ZigTypeIdStruct) {
+ add_node_error(g, dst_use_node,
+ buf_sprintf("expected struct, found '%s'", buf_ptr(&target_import->name)));
+ get_container_scope(dst_use_node->owner)->any_imports_failed = true;
+ return;
+ }
+
if (get_container_scope(target_import)->any_imports_failed) {
get_container_scope(dst_use_node->owner)->any_imports_failed = true;
}