mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 21:08:36 +00:00
parent
3ce857d054
commit
456f3c026b
@ -21401,7 +21401,7 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
|
||||
try operand_ty.resolveLayout(pt);
|
||||
const enum_ty = switch (operand_ty.zigTypeTag(zcu)) {
|
||||
.enum_literal => {
|
||||
const val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, operand, undefined);
|
||||
const val = (try sema.resolveDefinedValue(block, operand_src, operand)).?;
|
||||
const tag_name = ip.indexToKey(val.toIntern()).enum_literal;
|
||||
return sema.addNullTerminatedStrLit(tag_name);
|
||||
},
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
comptime {
|
||||
const undef: @Type(.enum_literal) = undefined;
|
||||
_ = @tagName(undef);
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:18: error: use of undefined value here causes undefined behavior
|
||||
Loading…
x
Reference in New Issue
Block a user