authorgravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2019-04-06 11:04:55+02:00
committergravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2019-04-06 11:04:55+02:00
log65cf5a8e44f299bb24e139cc25df717f1ddba455
treefc0237b5716eef232a14aed6c13f8c6b6a554859
parent3109c898505820fb8cc89f87759292a9aebe3db1

removed todo comment and added test


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,
1630916309
1631016310 ZigType *ptr_type;
1631116311 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'
1631516312 ptr_type = get_pointer_to_type(ira->codegen, type_entry->data.array.child_type, ptr_ptr_type->data.pointer.is_const);
1631616313 } else if (is_array_ref(type_entry)) {
1631716314 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" {
2727 mem.copy(u8, target[0..], source);
2828 mangleString(target[0..]);
2929 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);
3035}
36
3137fn mangleString(s: []u8) void {
3238 for (s) |*c| {
3339 c.* += 1;