stage2: implement array literal with explicit type
New ZIR instruction: elem_ptr_imm This saves some memory for array literals since the element indexes are communicated as immediate values rather than as references to other ZIR instructions.
This commit is contained in:
@@ -33,8 +33,13 @@ test "array init with mult" {
|
||||
var i: [8]u8 = [2]u8{ a, 'b' } ** 4;
|
||||
try expect(std.mem.eql(u8, &i, "abababab"));
|
||||
|
||||
// this should cause a Value.repeated to be emitted in AIR.
|
||||
// TODO: find a way to test that this is actually getting emmited
|
||||
var j: [4]u8 = [1]u8{'a'} ** 4;
|
||||
try expect(std.mem.eql(u8, &j, "aaaa"));
|
||||
}
|
||||
|
||||
test "array literal with explicit type" {
|
||||
const hex_mult: [4]u16 = .{ 4096, 256, 16, 1 };
|
||||
|
||||
try expect(hex_mult.len == 4);
|
||||
try expect(hex_mult[1] == 256);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user