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) {...@@ -4174,8 +4174,14 @@ static void add_async_error_notes(CodeGen *g, ErrorMsg *msg, ZigFn *fn) {
4174 assert(fn->inferred_async_node != inferred_async_checking);4174 assert(fn->inferred_async_node != inferred_async_checking);
4175 assert(fn->inferred_async_node != inferred_async_none);4175 assert(fn->inferred_async_node != inferred_async_none);
4176 if (fn->inferred_async_fn != nullptr) {4176 if (fn->inferred_async_fn != nullptr) {
4177 ErrorMsg *new_msg = add_error_note(g, msg, fn->inferred_async_node,4177 ErrorMsg *new_msg;
4178 buf_sprintf("async function call here"));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 }
4179 return add_async_error_notes(g, new_msg, fn->inferred_async_fn);4185 return add_async_error_notes(g, new_msg, fn->inferred_async_fn);
4180 } else if (fn->inferred_async_node->type == NodeTypeFnProto) {4186 } else if (fn->inferred_async_node->type == NodeTypeFnProto) {
4181 add_error_note(g, msg, fn->inferred_async_node,4187 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) {...@@ -4185,7 +4191,7 @@ static void add_async_error_notes(CodeGen *g, ErrorMsg *msg, ZigFn *fn) {
4185 buf_sprintf("suspends here"));4191 buf_sprintf("suspends here"));
4186 } else if (fn->inferred_async_node->type == NodeTypeAwaitExpr) {4192 } else if (fn->inferred_async_node->type == NodeTypeAwaitExpr) {
4187 add_error_note(g, msg, fn->inferred_async_node,4193 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"));
4189 } else if (fn->inferred_async_node->type == NodeTypeFnCallExpr &&4195 } else if (fn->inferred_async_node->type == NodeTypeFnCallExpr &&
4190 fn->inferred_async_node->data.fn_call_expr.is_builtin)4196 fn->inferred_async_node->data.fn_call_expr.is_builtin)
4191 {4197 {
...@@ -4240,6 +4246,16 @@ static Error analyze_callee_async(CodeGen *g, ZigFn *fn, ZigFn *callee, AstNode...@@ -4240,6 +4246,16 @@ static Error analyze_callee_async(CodeGen *g, ZigFn *fn, ZigFn *callee, AstNode
4240 add_async_error_notes(g, msg, fn);4246 add_async_error_notes(g, msg, fn);
4241 return ErrorSemanticAnalyzeFail;4247 return ErrorSemanticAnalyzeFail;
4242 }4248 }
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 }
4243 return ErrorIsAsync;4259 return ErrorIsAsync;
4244 }4260 }
4245 return ErrorNone;4261 return ErrorNone;
src/ir.cpp+3-1
...@@ -10640,7 +10640,9 @@ static void ir_finish_bb(IrAnalyze *ira) {...@@ -10640,7 +10640,9 @@ static void ir_finish_bb(IrAnalyze *ira) {
1064010640
10641static IrInstruction *ir_unreach_error(IrAnalyze *ira) {10641static IrInstruction *ir_unreach_error(IrAnalyze *ira) {
10642 ira->old_bb_index = SIZE_MAX;10642 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 }
10644 return ira->codegen->unreach_instruction;10646 return ira->codegen->unreach_instruction;
10645}10647}
1064610648
test/compile_errors.zig+4-4
...@@ -273,7 +273,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -273,7 +273,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
273 \\}273 \\}
274 ,274 ,
275 "tmp.zig:1:1: error: function with calling convention 'ccc' cannot be async",275 "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",
277 );277 );
278278
279 cases.add(279 cases.add(
...@@ -507,11 +507,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -507,11 +507,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
507507
508 cases.add(508 cases.add(
509 "@sizeOf bad type",509 "@sizeOf bad type",
510 \\export fn entry() void {510 \\export fn entry() usize {
511 \\ _ = @sizeOf(@typeOf(null));511 \\ return @sizeOf(@typeOf(null));
512 \\}512 \\}
513 ,513 ,
514 "tmp.zig:2:17: error: no size available for type '(null)'",514 "tmp.zig:2:20: error: no size available for type '(null)'",
515 );515 );
516516
517 cases.add(517 cases.add(