mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
parent
a736dfe6a1
commit
aff7b38838
15
src/ir.cpp
15
src/ir.cpp
@ -20884,19 +20884,20 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,
|
||||
for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) {
|
||||
IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i];
|
||||
|
||||
IrInstruction *start_value = range->start->child;
|
||||
IrInstruction *start_value_uncasted = range->start->child;
|
||||
if (type_is_invalid(start_value_uncasted->value.type))
|
||||
return ira->codegen->invalid_instruction;
|
||||
IrInstruction *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type);
|
||||
if (type_is_invalid(start_value->value.type))
|
||||
return ira->codegen->invalid_instruction;
|
||||
|
||||
IrInstruction *end_value = range->end->child;
|
||||
IrInstruction *end_value_uncasted = range->end->child;
|
||||
if (type_is_invalid(end_value_uncasted->value.type))
|
||||
return ira->codegen->invalid_instruction;
|
||||
IrInstruction *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type);
|
||||
if (type_is_invalid(end_value->value.type))
|
||||
return ira->codegen->invalid_instruction;
|
||||
|
||||
if (start_value->value.type->id != ZigTypeIdEnum) {
|
||||
ir_add_error(ira, range->start, buf_sprintf("not an enum type"));
|
||||
return ira->codegen->invalid_instruction;
|
||||
}
|
||||
|
||||
BigInt start_index;
|
||||
bigint_init_bigint(&start_index, &start_value->value.data.x_enum_tag);
|
||||
|
||||
|
||||
@ -203,7 +203,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\const InvalidToken = struct {};
|
||||
\\const ExpectedVarDeclOrFn = struct {};
|
||||
,
|
||||
"tmp.zig:4:9: error: not an enum type",
|
||||
"tmp.zig:4:9: error: expected type '@TagType(Error)', found 'type'",
|
||||
);
|
||||
|
||||
cases.addTest(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user