diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-01-26 10:37:18 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-01-26 10:37:18 -0500 |
| commit | ad3e2a5da07fbfe02e0152eb3fc408a7bcf36e3c (patch) | |
| tree | a15ea8b33d5de33d545f9010eebb6d99be619c75 /src | |
| parent | f7670882aff5fb3a943057edd9da34d053b5fe59 (diff) | |
| download | zig-ad3e2a5da07fbfe02e0152eb3fc408a7bcf36e3c.tar.gz zig-ad3e2a5da07fbfe02e0152eb3fc408a7bcf36e3c.zip | |
fix compiler crash on function with invalid return type
closes #722
Diffstat (limited to 'src')
| -rw-r--r-- | src/analyze.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 49f8e093a0..a97ec513ad 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -1376,6 +1376,10 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c fn_type_id.return_type = (fn_proto->return_type == nullptr) ? g->builtin_types.entry_void : analyze_type_expr(g, child_scope, fn_proto->return_type); + if (type_is_invalid(fn_type_id.return_type)) { + return g->builtin_types.entry_invalid; + } + if (fn_type_id.cc != CallingConventionUnspecified && !type_allowed_in_extern(g, fn_type_id.return_type)) { add_node_error(g, fn_proto->return_type, buf_sprintf("return type '%s' not allowed in function with calling convention '%s'", @@ -1386,7 +1390,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c switch (fn_type_id.return_type->id) { case TypeTableEntryIdInvalid: - return g->builtin_types.entry_invalid; + zig_unreachable(); case TypeTableEntryIdUndefLit: case TypeTableEntryIdNullLit: |
