aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-04-09 17:35:26 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-04-09 17:35:26 -0700
commite66ed0f2e230ad3aed9a4207997df0ab7c99c2d6 (patch)
treedfc7985aac46309e4b9b9028d1b63485e0142879 /src/analyze.cpp
parent707131e37b2ee384d46c26ada83f3c83edf7278d (diff)
downloadzig-e66ed0f2e230ad3aed9a4207997df0ab7c99c2d6.tar.gz
zig-e66ed0f2e230ad3aed9a4207997df0ab7c99c2d6.zip
add error for assigning null to non-nullable pointer
closes #133
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index b988d663f9..fb6894eba0 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -3391,12 +3391,15 @@ static TypeTableEntry *analyze_null_literal_expr(CodeGen *g, ImportTableEntry *i
assert(node->type == NodeTypeNullLiteral);
if (!expected_type) {
- add_node_error(g, node,
- buf_sprintf("unable to determine null type"));
+ add_node_error(g, node, buf_sprintf("unable to determine null type"));
return g->builtin_types.entry_invalid;
}
- assert(expected_type->id == TypeTableEntryIdMaybe);
+ if (expected_type->id != TypeTableEntryIdMaybe) {
+ add_node_error(g, node,
+ buf_sprintf("expected maybe type, got '%s'", buf_ptr(&expected_type->name)));
+ return g->builtin_types.entry_invalid;
+ }
node->data.null_literal.resolved_struct_val_expr.type_entry = expected_type;
node->data.null_literal.resolved_struct_val_expr.source_node = node;