fix regressions

This commit is contained in:
Andrew Kelley 2019-08-29 22:44:07 -04:00
parent 03910925f0
commit e9a4bcbcc6
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
3 changed files with 26 additions and 8 deletions

View File

@ -4174,8 +4174,14 @@ static void add_async_error_notes(CodeGen *g, ErrorMsg *msg, ZigFn *fn) {
assert(fn->inferred_async_node != inferred_async_checking);
assert(fn->inferred_async_node != inferred_async_none);
if (fn->inferred_async_fn != nullptr) {
ErrorMsg *new_msg = add_error_note(g, msg, fn->inferred_async_node,
buf_sprintf("async function call here"));
ErrorMsg *new_msg;
if (fn->inferred_async_node->type == NodeTypeAwaitExpr) {
new_msg = add_error_note(g, msg, fn->inferred_async_node,
buf_create_from_str("await here is a suspend point"));
} else {
new_msg = add_error_note(g, msg, fn->inferred_async_node,
buf_sprintf("async function call here"));
}
return add_async_error_notes(g, new_msg, fn->inferred_async_fn);
} else if (fn->inferred_async_node->type == NodeTypeFnProto) {
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) {
buf_sprintf("suspends here"));
} else if (fn->inferred_async_node->type == NodeTypeAwaitExpr) {
add_error_note(g, msg, fn->inferred_async_node,
buf_sprintf("await is a suspend point"));
buf_sprintf("await here is a suspend point"));
} else if (fn->inferred_async_node->type == NodeTypeFnCallExpr &&
fn->inferred_async_node->data.fn_call_expr.is_builtin)
{
@ -4240,6 +4246,16 @@ static Error analyze_callee_async(CodeGen *g, ZigFn *fn, ZigFn *callee, AstNode
add_async_error_notes(g, msg, fn);
return ErrorSemanticAnalyzeFail;
}
if (fn->assumed_non_async != nullptr) {
ErrorMsg *msg = add_node_error(g, fn->proto_node,
buf_sprintf("unable to infer whether '%s' should be async",
buf_ptr(&fn->symbol_name)));
add_error_note(g, msg, fn->assumed_non_async,
buf_sprintf("assumed to be non-async here"));
add_async_error_notes(g, msg, fn);
fn->anal_state = FnAnalStateInvalid;
return ErrorSemanticAnalyzeFail;
}
return ErrorIsAsync;
}
return ErrorNone;

View File

@ -10640,7 +10640,9 @@ static void ir_finish_bb(IrAnalyze *ira) {
static IrInstruction *ir_unreach_error(IrAnalyze *ira) {
ira->old_bb_index = SIZE_MAX;
assert(ira->new_irb.exec->first_err_trace_msg != nullptr);
if (ira->new_irb.exec->first_err_trace_msg == nullptr) {
ira->new_irb.exec->first_err_trace_msg = ira->codegen->trace_err;
}
return ira->codegen->unreach_instruction;
}

View File

@ -273,7 +273,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\}
,
"tmp.zig:1:1: error: function with calling convention 'ccc' cannot be async",
"tmp.zig:3:18: note: await is a suspend point",
"tmp.zig:3:18: note: await here is a suspend point",
);
cases.add(
@ -507,11 +507,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
"@sizeOf bad type",
\\export fn entry() void {
\\ _ = @sizeOf(@typeOf(null));
\\export fn entry() usize {
\\ return @sizeOf(@typeOf(null));
\\}
,
"tmp.zig:2:17: error: no size available for type '(null)'",
"tmp.zig:2:20: error: no size available for type '(null)'",
);
cases.add(