mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
parent
aff7b38838
commit
da9d8a6ecf
15
src/ir.cpp
15
src/ir.cpp
@ -9573,6 +9573,21 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT
|
||||
continue;
|
||||
}
|
||||
|
||||
if (prev_type->id == ZigTypeIdEnum && cur_type->id == ZigTypeIdEnumLiteral) {
|
||||
TypeEnumField *field = find_enum_type_field(prev_type, cur_inst->value.data.x_enum_literal);
|
||||
if (field != nullptr) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (cur_type->id == ZigTypeIdEnum && prev_type->id == ZigTypeIdEnumLiteral) {
|
||||
TypeEnumField *field = find_enum_type_field(cur_type, prev_inst->value.data.x_enum_literal);
|
||||
if (field != nullptr) {
|
||||
prev_inst = cur_inst;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (prev_type->id == ZigTypeIdPointer && prev_type->data.pointer.ptr_len == PtrLenC &&
|
||||
(cur_type->id == ZigTypeIdComptimeInt || cur_type->id == ZigTypeIdInt))
|
||||
{
|
||||
|
||||
@ -913,3 +913,13 @@ test "enum literal cast to enum" {
|
||||
var color2 = Color.Auto;
|
||||
expect(color1 == color2);
|
||||
}
|
||||
|
||||
test "peer type resolution with enum literal" {
|
||||
const Items = enum {
|
||||
one,
|
||||
two,
|
||||
};
|
||||
|
||||
expect(Items.two == .two);
|
||||
expect(.two == Items.two);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user