mirror of
https://github.com/ziglang/zig.git
synced 2025-12-30 18:13:19 +00:00
parent
bf62cb453b
commit
587ef60a28
@ -7580,7 +7580,8 @@ fn zirEnumToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
|
||||
const enum_tag: Air.Inst.Ref = switch (operand_ty.zigTypeTag()) {
|
||||
.Enum => operand,
|
||||
.Union => blk: {
|
||||
const tag_ty = operand_ty.unionTagType() orelse {
|
||||
const union_ty = try sema.resolveTypeFields(operand_ty);
|
||||
const tag_ty = union_ty.unionTagType() orelse {
|
||||
return sema.fail(
|
||||
block,
|
||||
operand_src,
|
||||
@ -22713,7 +22714,8 @@ fn fieldPtr(
|
||||
return inst;
|
||||
}
|
||||
}
|
||||
if (child_type.unionTagType()) |enum_ty| {
|
||||
const union_ty = try sema.resolveTypeFields(child_type);
|
||||
if (union_ty.unionTagType()) |enum_ty| {
|
||||
if (enum_ty.enumFieldIndex(field_name)) |field_index| {
|
||||
const field_index_u32 = @intCast(u32, field_index);
|
||||
var anon_decl = try block.startAnonDecl();
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
const T = union(enum) {
|
||||
a,
|
||||
pub fn f(self: T) void {
|
||||
_ = self;
|
||||
}
|
||||
};
|
||||
pub export fn entry() void {
|
||||
T.a.f();
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :8:8: error: no field or member function named 'f' in '@typeInfo(tmp.T).Union.tag_type.?'
|
||||
// :1:11: note: enum declared here
|
||||
Loading…
x
Reference in New Issue
Block a user