| author | |
| committer | |
| log | 3829e200ecc251d6b55686c24bdbd579c5a2246a |
| tree | 6f7e67f54f17f15e67d694fb2bef4e74f8a13238 |
| parent | 3c05ad401282b0eb8b9960a2b521fc1375c4087e |
| signature | Commit is signed but in an unrecognized format. |
2 files changed, 9 insertions(+), 1 deletions(-)
src/ir.cpp+1-1| ... | ... | @@ -10153,7 +10153,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour |
| 10153 | 10153 | return ira->codegen->invalid_instruction; |
| 10154 | 10154 | } |
| 10155 | 10155 | |
| 10156 | assert(actual_type->id == ZigTypeIdInt); | |
| 10156 | assert(actual_type->id == ZigTypeIdInt || actual_type->id == ZigTypeIdComptimeInt); | |
| 10157 | 10157 | |
| 10158 | 10158 | if (instr_is_comptime(target)) { |
| 10159 | 10159 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); |
test/cases/cast.zig+8| ... | ... | @@ -462,3 +462,11 @@ test "implicit cast comptime numbers to any type when the value fits" { |
| 462 | 462 | var b: u8 = a; |
| 463 | 463 | assert(b == 255); |
| 464 | 464 | } |
| 465 | ||
| 466 | test "@intToEnum passed a comptime_int to an enum with one item" { | |
| 467 | const E = enum { | |
| 468 | A, | |
| 469 | }; | |
| 470 | const x = @intToEnum(E, 0); | |
| 471 | assert(x == E.A); | |
| 472 | } |