refactor type_requires_comptime to have possible error

fixes a compiler crash when building
https://github.com/AndreaOrru/zen
This commit is contained in:
Andrew Kelley
2018-11-24 16:15:58 -05:00
parent 56a8f2b018
commit 3d2752cc36
4 changed files with 129 additions and 84 deletions

View File

@@ -6281,8 +6281,14 @@ static void do_code_gen(CodeGen *g) {
}
if (ir_get_var_is_comptime(var))
continue;
if (type_requires_comptime(var->value->type))
continue;
switch (type_requires_comptime(g, var->value->type)) {
case ReqCompTimeInvalid:
zig_unreachable();
case ReqCompTimeYes:
continue;
case ReqCompTimeNo:
break;
}
if (var->src_arg_index == SIZE_MAX) {
var->value_ref = build_alloca(g, var->value->type, buf_ptr(&var->name), var->align_bytes);