parent
2f633452bb
commit
77a1a216d2
19
src/ir.cpp
19
src/ir.cpp
|
@ -13736,7 +13736,16 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
|
|||
create_const_enum(child_type, &field->value), child_type,
|
||||
ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile);
|
||||
}
|
||||
} else if (child_type->id == TypeTableEntryIdUnion &&
|
||||
}
|
||||
ScopeDecls *container_scope = get_container_scope(child_type);
|
||||
if (container_scope != nullptr) {
|
||||
auto entry = container_scope->decl_table.maybe_get(field_name);
|
||||
Tld *tld = entry ? entry->value : nullptr;
|
||||
if (tld) {
|
||||
return ir_analyze_decl_ref(ira, &field_ptr_instruction->base, tld);
|
||||
}
|
||||
}
|
||||
if (child_type->id == TypeTableEntryIdUnion &&
|
||||
(child_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr ||
|
||||
child_type->data.unionation.decl_node->data.container_decl.auto_enum))
|
||||
{
|
||||
|
@ -13753,14 +13762,6 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
|
|||
ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile);
|
||||
}
|
||||
}
|
||||
ScopeDecls *container_scope = get_container_scope(child_type);
|
||||
if (container_scope != nullptr) {
|
||||
auto entry = container_scope->decl_table.maybe_get(field_name);
|
||||
Tld *tld = entry ? entry->value : nullptr;
|
||||
if (tld) {
|
||||
return ir_analyze_decl_ref(ira, &field_ptr_instruction->base, tld);
|
||||
}
|
||||
}
|
||||
ir_add_error(ira, &field_ptr_instruction->base,
|
||||
buf_sprintf("container '%s' has no member called '%s'",
|
||||
buf_ptr(&child_type->name), buf_ptr(field_name)));
|
||||
|
|
|
@ -272,3 +272,15 @@ const PartialInstWithPayload = union(enum) {
|
|||
Compiled: i32,
|
||||
};
|
||||
|
||||
|
||||
test "access a member of tagged union with conflicting enum tag name" {
|
||||
const Bar = union(enum) {
|
||||
A: A,
|
||||
B: B,
|
||||
|
||||
const A = u8;
|
||||
const B = void;
|
||||
};
|
||||
|
||||
comptime assert(Bar.A == u8);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue