-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
stage1 and stage2: closes #7120 #7122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6362,7 +6362,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNod | |
BuiltinFnEntry *builtin_fn = entry->value; | ||
size_t actual_param_count = node->data.fn_call_expr.params.length; | ||
|
||
if (builtin_fn->param_count != SIZE_MAX && builtin_fn->param_count != actual_param_count) { | ||
if (builtin_fn->param_count != SIZE_MAX && builtin_fn->param_count != actual_param_count) { | ||
add_node_error(irb->codegen, node, | ||
buf_sprintf("expected %" ZIG_PRI_usize " argument(s), found %" ZIG_PRI_usize, | ||
builtin_fn->param_count, actual_param_count)); | ||
|
@@ -8576,7 +8576,7 @@ static IrInstSrc *ir_gen_for_expr(IrBuilderSrc *irb, Scope *parent_scope, AstNod | |
|
||
if (is_duplicate_label(irb->codegen, child_scope, node, node->data.for_expr.name)) | ||
return irb->codegen->invalid_inst_src; | ||
|
||
ZigList<IrInstSrc *> incoming_values = {0}; | ||
ZigList<IrBasicBlockSrc *> incoming_blocks = {0}; | ||
ScopeLoop *loop_scope = create_loop_scope(irb->codegen, node, child_scope); | ||
|
@@ -20854,7 +20854,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, | |
expected_return_type->id != ZigTypeIdErrorUnion && expected_return_type->id != ZigTypeIdErrorSet) | ||
{ | ||
if (call_result_loc->id == ResultLocIdReturn) { | ||
add_error_note(ira->codegen, ira->new_irb.exec->first_err_trace_msg, | ||
add_error_note(ira->codegen, ira->new_irb.exec->first_err_trace_msg, | ||
ira->explicit_return_type_source_node, buf_sprintf("function cannot return an error")); | ||
} else { | ||
add_error_note(ira->codegen, ira->new_irb.exec->first_err_trace_msg, result_loc->base.source_node, | ||
|
@@ -29479,7 +29479,7 @@ static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | |
} | ||
} | ||
} else if(!switch_type->data.enumeration.non_exhaustive && switch_type->data.enumeration.src_field_count == instruction->range_count) { | ||
ir_add_error_node(ira, instruction->else_prong, | ||
ir_add_error_node(ira, instruction->else_prong, | ||
buf_sprintf("unreachable else prong, all cases already handled")); | ||
return ira->codegen->invalid_inst_gen; | ||
} | ||
|
@@ -29544,6 +29544,23 @@ static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | |
} | ||
} | ||
} | ||
} else { | ||
if (!type_is_global_error_set(switch_type)) { | ||
bool needs_else = false; | ||
for (uint32_t i = 0; i < switch_type->data.error_set.err_count; i += 1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this a more expensive version of |
||
ErrorTableEntry *err_entry = switch_type->data.error_set.errors[i]; | ||
|
||
AstNode *prev_node = field_prev_uses[err_entry->value]; | ||
if (prev_node == nullptr) { | ||
needs_else = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Anyway, the indentation is off and you can exit with a |
||
} | ||
} | ||
if (!needs_else) { | ||
ir_add_error_node(ira, instruction->else_prong, | ||
buf_sprintf("unreachable else prong, all cases already handled")); | ||
return ira->codegen->invalid_inst_gen; | ||
} | ||
} | ||
} | ||
|
||
heap::c_allocator.deallocate(field_prev_uses, field_prev_uses_count); | ||
|
@@ -29600,7 +29617,7 @@ static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | |
ir_add_error(ira, &instruction->base.base, buf_sprintf("switch must handle all possibilities")); | ||
return ira->codegen->invalid_inst_gen; | ||
} else if(handles_all_cases && instruction->else_prong != nullptr) { | ||
ir_add_error_node(ira, instruction->else_prong, | ||
ir_add_error_node(ira, instruction->else_prong, | ||
buf_sprintf("unreachable else prong, all cases already handled")); | ||
return ira->codegen->invalid_inst_gen; | ||
} | ||
|
@@ -29639,7 +29656,7 @@ static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | |
} | ||
|
||
if(seenTrue == 1 && seenFalse == 1 && instruction->else_prong != nullptr) { | ||
ir_add_error_node(ira, instruction->else_prong, | ||
ir_add_error_node(ira, instruction->else_prong, | ||
buf_sprintf("unreachable else prong, all cases already handled")); | ||
return ira->codegen->invalid_inst_gen; | ||
} | ||
|
@@ -29677,7 +29694,7 @@ static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | |
} | ||
} | ||
prevs.deinit(); | ||
} | ||
} | ||
return ir_const_void(ira, &instruction->base.base); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can save a whole indentation level.