authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-08-29 22:44:07-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-08-29 22:44:07-04:00
loge9a4bcbcc6ac89c5526a6baaf2b0df49d0577eb4
tree1c8b6c29b99f0cc7f22307674dd58634b1910d12
parent03910925f06f6127e81de47ff22ce4d24ca565b2
signaturelock-open Commit is signed but in an unrecognized format.

fix regressions


3 files changed, 26 insertions(+), 8 deletions(-)

src/analyze.cpp+19-3
......@@ -4174,8 +4174,14 @@ static void add_async_error_notes(CodeGen *g, ErrorMsg *msg, ZigFn *fn) {
41744174 assert(fn->inferred_async_node != inferred_async_checking);
41754175 assert(fn->inferred_async_node != inferred_async_none);
41764176 if (fn->inferred_async_fn != nullptr) {
4177 ErrorMsg *new_msg = add_error_note(g, msg, fn->inferred_async_node,
4178 buf_sprintf("async function call here"));
4177 ErrorMsg *new_msg;
4178 if (fn->inferred_async_node->type == NodeTypeAwaitExpr) {
4179 new_msg = add_error_note(g, msg, fn->inferred_async_node,
4180 buf_create_from_str("await here is a suspend point"));
4181 } else {
4182 new_msg = add_error_note(g, msg, fn->inferred_async_node,
4183 buf_sprintf("async function call here"));
4184 }
41794185 return add_async_error_notes(g, new_msg, fn->inferred_async_fn);
41804186 } else if (fn->inferred_async_node->type == NodeTypeFnProto) {
41814187 add_error_note(g, msg, fn->inferred_async_node,
......@@ -4185,7 +4191,7 @@ static void add_async_error_notes(CodeGen *g, ErrorMsg *msg, ZigFn *fn) {
41854191 buf_sprintf("suspends here"));
41864192 } else if (fn->inferred_async_node->type == NodeTypeAwaitExpr) {
41874193 add_error_note(g, msg, fn->inferred_async_node,
4188 buf_sprintf("await is a suspend point"));
4194 buf_sprintf("await here is a suspend point"));
41894195 } else if (fn->inferred_async_node->type == NodeTypeFnCallExpr &&
41904196 fn->inferred_async_node->data.fn_call_expr.is_builtin)
41914197 {
......@@ -4240,6 +4246,16 @@ static Error analyze_callee_async(CodeGen *g, ZigFn *fn, ZigFn *callee, AstNode
42404246 add_async_error_notes(g, msg, fn);
42414247 return ErrorSemanticAnalyzeFail;
42424248 }
4249 if (fn->assumed_non_async != nullptr) {
4250 ErrorMsg *msg = add_node_error(g, fn->proto_node,
4251 buf_sprintf("unable to infer whether '%s' should be async",
4252 buf_ptr(&fn->symbol_name)));
4253 add_error_note(g, msg, fn->assumed_non_async,
4254 buf_sprintf("assumed to be non-async here"));
4255 add_async_error_notes(g, msg, fn);
4256 fn->anal_state = FnAnalStateInvalid;
4257 return ErrorSemanticAnalyzeFail;
4258 }
42434259 return ErrorIsAsync;
42444260 }
42454261 return ErrorNone;
src/ir.cpp+3-1
......@@ -10640,7 +10640,9 @@ static void ir_finish_bb(IrAnalyze *ira) {
1064010640
1064110641static IrInstruction *ir_unreach_error(IrAnalyze *ira) {
1064210642 ira->old_bb_index = SIZE_MAX;
10643 assert(ira->new_irb.exec->first_err_trace_msg != nullptr);
10643 if (ira->new_irb.exec->first_err_trace_msg == nullptr) {
10644 ira->new_irb.exec->first_err_trace_msg = ira->codegen->trace_err;
10645 }
1064410646 return ira->codegen->unreach_instruction;
1064510647}
1064610648
test/compile_errors.zig+4-4
......@@ -273,7 +273,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
273273 \\}
274274 ,
275275 "tmp.zig:1:1: error: function with calling convention 'ccc' cannot be async",
276 "tmp.zig:3:18: note: await is a suspend point",
276 "tmp.zig:3:18: note: await here is a suspend point",
277277 );
278278
279279 cases.add(
......@@ -507,11 +507,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
507507
508508 cases.add(
509509 "@sizeOf bad type",
510 \\export fn entry() void {
511 \\ _ = @sizeOf(@typeOf(null));
510 \\export fn entry() usize {
511 \\ return @sizeOf(@typeOf(null));
512512 \\}
513513 ,
514 "tmp.zig:2:17: error: no size available for type '(null)'",
514 "tmp.zig:2:20: error: no size available for type '(null)'",
515515 );
516516
517517 cases.add(