mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
fix assertion failure related to @intToEnum
This commit is contained in:
parent
3c05ad4012
commit
3829e200ec
@ -10153,7 +10153,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour
|
||||
return ira->codegen->invalid_instruction;
|
||||
}
|
||||
|
||||
assert(actual_type->id == ZigTypeIdInt);
|
||||
assert(actual_type->id == ZigTypeIdInt || actual_type->id == ZigTypeIdComptimeInt);
|
||||
|
||||
if (instr_is_comptime(target)) {
|
||||
ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);
|
||||
|
||||
@ -462,3 +462,11 @@ test "implicit cast comptime numbers to any type when the value fits" {
|
||||
var b: u8 = a;
|
||||
assert(b == 255);
|
||||
}
|
||||
|
||||
test "@intToEnum passed a comptime_int to an enum with one item" {
|
||||
const E = enum {
|
||||
A,
|
||||
};
|
||||
const x = @intToEnum(E, 0);
|
||||
assert(x == E.A);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user