From ff7e826b82b097ffb688e809b6d762d8d56c0f3c Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 15 Aug 2019 18:54:23 -0400 Subject: [PATCH] fix crash with sometimes type not being resolved --- src/codegen.cpp | 4 ++++ test/stage1/behavior/async_fn.zig | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/codegen.cpp b/src/codegen.cpp index 982cb821b..ebd3c72b5 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -7004,6 +7004,8 @@ static void do_code_gen(CodeGen *g) { ZigType *ptr_type = instruction->base.value.type; assert(ptr_type->id == ZigTypeIdPointer); ZigType *child_type = ptr_type->data.pointer.child_type; + if (type_resolve(g, child_type, ResolveStatusSizeKnown)) + zig_unreachable(); if (!type_has_bits(child_type)) continue; if (instruction->base.ref_count == 0) @@ -7015,6 +7017,8 @@ static void do_code_gen(CodeGen *g) { continue; } } + if (type_resolve(g, child_type, ResolveStatusLLVMFull)) + zig_unreachable(); instruction->base.llvm_value = build_alloca(g, child_type, instruction->name_hint, get_ptr_align(g, ptr_type)); } diff --git a/test/stage1/behavior/async_fn.zig b/test/stage1/behavior/async_fn.zig index 96b7b0213..1536f0291 100644 --- a/test/stage1/behavior/async_fn.zig +++ b/test/stage1/behavior/async_fn.zig @@ -734,3 +734,10 @@ test "alignment of local variables in async functions" { }; S.doTheTest(); } + +test "no reason to resolve frame still works" { + _ = async simpleNothing(); +} +fn simpleNothing() void { + var x: i32 = 1234; +}