aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorVexu <git@vexu.eu>2020-07-07 23:31:38 +0300
committerAndrew Kelley <andrew@ziglang.org>2020-07-08 03:09:41 +0000
commit5667a21b1e7b8aa2dfcefed81d2b594029a116db (patch)
tree07ce6306793ab5486b92d873987030c7f4601c32 /src/analyze.cpp
parent597a36367305cdb63ffe25af707d708ef9376a7a (diff)
downloadzig-5667a21b1e7b8aa2dfcefed81d2b594029a116db.tar.gz
zig-5667a21b1e7b8aa2dfcefed81d2b594029a116db.zip
fix missing check on extern variables with no type
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 699b121276..afe0fe6849 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -4012,6 +4012,10 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) {
} else if (!is_extern) {
add_node_error(g, source_node, buf_sprintf("variables must be initialized"));
implicit_type = g->builtin_types.entry_invalid;
+ } else if (explicit_type == nullptr) {
+ // extern variable without explicit type
+ add_node_error(g, source_node, buf_sprintf("unable to infer variable type"));
+ implicit_type = g->builtin_types.entry_invalid;
}
ZigType *type = explicit_type ? explicit_type : implicit_type;