remove type coercion from array values to references
* Implements #3768. This is a sweeping breaking change that requires many (trivial) edits to Zig source code. Array values no longer coerced to slices; however one may use `&` to obtain a reference to an array value, which may then be coerced to a slice. * Adds `IrInstruction::dump`, for debugging purposes. It's useful to call to inspect the instruction when debugging Zig IR. * Fixes bugs with result location semantics. See the new behavior test cases, and compile error test cases. * Fixes bugs with `@typeInfo` not properly resolving const values. * Behavior tests are passing but std lib tests are not yet. There is more work to do before merging this branch.
This commit is contained in:
@@ -201,7 +201,7 @@ pub fn PackedIntArrayEndian(comptime Int: type, comptime endian: builtin.Endian,
|
||||
///Return the Int stored at index
|
||||
pub fn get(self: Self, index: usize) Int {
|
||||
debug.assert(index < int_count);
|
||||
return Io.get(self.bytes, index, 0);
|
||||
return Io.get(&self.bytes, index, 0);
|
||||
}
|
||||
|
||||
///Copy int into the array at index
|
||||
@@ -528,16 +528,7 @@ test "PackedInt(Array/Slice) sliceCast" {
|
||||
test "PackedInt(Array/Slice)Endian" {
|
||||
{
|
||||
const PackedArrayBe = PackedIntArrayEndian(u4, .Big, 8);
|
||||
var packed_array_be = PackedArrayBe.init([_]u4{
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
});
|
||||
var packed_array_be = PackedArrayBe.init([_]u4{ 0, 1, 2, 3, 4, 5, 6, 7 });
|
||||
testing.expect(packed_array_be.bytes[0] == 0b00000001);
|
||||
testing.expect(packed_array_be.bytes[1] == 0b00100011);
|
||||
|
||||
@@ -563,16 +554,7 @@ test "PackedInt(Array/Slice)Endian" {
|
||||
|
||||
{
|
||||
const PackedArrayBe = PackedIntArrayEndian(u11, .Big, 8);
|
||||
var packed_array_be = PackedArrayBe.init([_]u11{
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
});
|
||||
var packed_array_be = PackedArrayBe.init([_]u11{ 0, 1, 2, 3, 4, 5, 6, 7 });
|
||||
testing.expect(packed_array_be.bytes[0] == 0b00000000);
|
||||
testing.expect(packed_array_be.bytes[1] == 0b00000000);
|
||||
testing.expect(packed_array_be.bytes[2] == 0b00000100);
|
||||
|
||||
Reference in New Issue
Block a user