diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-01-31 22:48:40 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-01-31 22:48:40 -0500 |
| commit | 5f518dbeb952186b7c11777b2454256c8c4fb9ac (patch) | |
| tree | 31adf1939ed1173c29199e98dfbab9d8b9f6056f /src/analyze.cpp | |
| parent | 5161d70620342749b1995fdaabb39220654cc941 (diff) | |
| download | zig-5f518dbeb952186b7c11777b2454256c8c4fb9ac.tar.gz zig-5f518dbeb952186b7c11777b2454256c8c4fb9ac.zip | |
*WIP* error sets converting std lib
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 3b98999081..f574892ebc 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -516,6 +516,7 @@ TypeTableEntry *get_maybe_type(CodeGen *g, TypeTableEntry *child_type) { TypeTableEntry *get_error_union_type(CodeGen *g, TypeTableEntry *err_set_type, TypeTableEntry *payload_type) { assert(err_set_type->id == TypeTableEntryIdErrorSet); + assert(!type_is_invalid(payload_type)); TypeId type_id = {}; type_id.id = TypeTableEntryIdErrorUnion; @@ -1409,6 +1410,11 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c } TypeTableEntry *specified_return_type = analyze_type_expr(g, child_scope, fn_proto->return_type); + if (type_is_invalid(specified_return_type)) { + fn_type_id.return_type = g->builtin_types.entry_invalid; + return g->builtin_types.entry_invalid; + } + if (fn_proto->auto_err_set) { TypeTableEntry *inferred_err_set_type = get_auto_err_set_type(g, fn_entry); fn_type_id.return_type = get_error_union_type(g, inferred_err_set_type, specified_return_type); @@ -1416,10 +1422,6 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c fn_type_id.return_type = specified_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'", |
