| author | |
| committer | |
| log | 5441f7767237709e8f3c05c2dc75070e835b4024 |
| tree | 2143e4fd903bdb6e2f86af6aa93ea6bb5d7a04b0 |
| parent | 142e77abbb8a88c2c6473921d0c600faf3d34a62 |
| signature | Commit is signed but in an unrecognized format. |
2 files changed, 16 insertions(+), 0 deletions(-)
src/ir.cpp+3| ... | ... | @@ -15207,6 +15207,9 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 15207 | 15207 | parent_ptr_type->data.pointer.is_const, parent_ptr_type->data.pointer.is_volatile, PtrLenSingle, |
| 15208 | 15208 | parent_ptr_align, 0, 0, parent_ptr_type->data.pointer.allow_zero); |
| 15209 | 15209 | |
| 15210 | if (value->value.special == ConstValSpecialRuntime) { | |
| 15211 | parent_result_loc->value.special = ConstValSpecialRuntime; | |
| 15212 | } | |
| 15210 | 15213 | result_loc->written = true; |
| 15211 | 15214 | result_loc->resolved_loc = ir_analyze_ptr_cast(ira, suspend_source_instr, parent_result_loc, |
| 15212 | 15215 | ptr_type, result_bit_cast->base.source_instruction, false); |
test/stage1/behavior/bitcast.zig+13| ... | ... | @@ -112,3 +112,16 @@ test "bitcast packed struct to integer and back" { |
| 112 | 112 | S.doTheTest(); |
| 113 | 113 | comptime S.doTheTest(); |
| 114 | 114 | } |
| 115 | ||
| 116 | test "implicit cast to error union by returning" { | |
| 117 | const S = struct { | |
| 118 | fn entry() void { | |
| 119 | expect((func(-1) catch unreachable) == maxInt(u64)); | |
| 120 | } | |
| 121 | pub fn func(sz: i64) anyerror!u64 { | |
| 122 | return @bitCast(u64, sz); | |
| 123 | } | |
| 124 | }; | |
| 125 | S.entry(); | |
| 126 | comptime S.entry(); | |
| 127 | } |