diff --git a/src/ir.cpp b/src/ir.cpp index 102ccc6f4a3680edba5c22e8a8d10367b80b7063..c572e3c885e8c690fce2d85148a8516f9e004680 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -16309,9 +16309,6 @@ static IrInstruction *ir_analyze_instruction_to_ptr_type(IrAnalyze *ira, ZigType *ptr_type; if (type_entry->id == ZigTypeIdArray) { - // TODO: Allow capturing pointer to const array. - // const a = "123"; for (a) |*c| continue; - // error: expected type '*u8', found '*const u8' ptr_type = get_pointer_to_type(ira->codegen, type_entry->data.array.child_type, ptr_ptr_type->data.pointer.is_const); } else if (is_array_ref(type_entry)) { ptr_type = get_pointer_to_type(ira->codegen, diff --git a/test/stage1/behavior/for.zig b/test/stage1/behavior/for.zig index b10dd14fa4e63fdf8ccc1d20fc860e6310272fcf..45a5334d1a3ea259952cb73a7a56b3772792fbec 100644 --- a/test/stage1/behavior/for.zig +++ b/test/stage1/behavior/for.zig @@ -27,7 +27,13 @@ test "for loop with pointer elem var" { mem.copy(u8, target[0..], source); mangleString(target[0..]); expect(mem.eql(u8, target, "bcdefgh")); + + for (source) |*c, i| + expect(@typeOf(c) == *const u8); + for (target) |*c, i| + expect(@typeOf(c) == *u8); } + fn mangleString(s: []u8) void { for (s) |*c| { c.* += 1;