| author | |
| committer | |
| log | 65cf5a8e44f299bb24e139cc25df717f1ddba455 |
| tree | fc0237b5716eef232a14aed6c13f8c6b6a554859 |
| parent | 3109c898505820fb8cc89f87759292a9aebe3db1 |
2 files changed, 6 insertions(+), 3 deletions(-)
src/ir.cpp-3| ... | ... | @@ -16309,9 +16309,6 @@ static IrInstruction *ir_analyze_instruction_to_ptr_type(IrAnalyze *ira, |
| 16309 | 16309 | |
| 16310 | 16310 | ZigType *ptr_type; |
| 16311 | 16311 | if (type_entry->id == ZigTypeIdArray) { |
| 16312 | // TODO: Allow capturing pointer to const array. | |
| 16313 | // const a = "123"; for (a) |*c| continue; | |
| 16314 | // error: expected type '*u8', found '*const u8' | |
| 16315 | 16312 | ptr_type = get_pointer_to_type(ira->codegen, type_entry->data.array.child_type, ptr_ptr_type->data.pointer.is_const); |
| 16316 | 16313 | } else if (is_array_ref(type_entry)) { |
| 16317 | 16314 | ptr_type = get_pointer_to_type(ira->codegen, |
test/stage1/behavior/for.zig+6| ... | ... | @@ -27,7 +27,13 @@ test "for loop with pointer elem var" { |
| 27 | 27 | mem.copy(u8, target[0..], source); |
| 28 | 28 | mangleString(target[0..]); |
| 29 | 29 | expect(mem.eql(u8, target, "bcdefgh")); |
| 30 | ||
| 31 | for (source) |*c, i| | |
| 32 | expect(@typeOf(c) == *const u8); | |
| 33 | for (target) |*c, i| | |
| 34 | expect(@typeOf(c) == *u8); | |
| 30 | 35 | } |
| 36 | ||
| 31 | 37 | fn mangleString(s: []u8) void { |
| 32 | 38 | for (s) |*c| { |
| 33 | 39 | c.* += 1; |