aboutsummaryrefslogtreecommitdiff
path: root/lib/std/array_list.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-11-27 03:30:39 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-11-27 03:37:50 -0500
commitbf3ac6615051143a9ef41180cd74e88de5dd573d (patch)
tree94571f5e6d408287928091c4dad6451d946d6434 /lib/std/array_list.zig
parent379d547603badb2667089c85454a2e3f5ede3342 (diff)
downloadzig-bf3ac6615051143a9ef41180cd74e88de5dd573d.tar.gz
zig-bf3ac6615051143a9ef41180cd74e88de5dd573d.zip
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.
Diffstat (limited to 'lib/std/array_list.zig')
-rw-r--r--lib/std/array_list.zig15
1 files changed, 4 insertions, 11 deletions
diff --git a/lib/std/array_list.zig b/lib/std/array_list.zig
index 26342d7833..6edc472c20 100644
--- a/lib/std/array_list.zig
+++ b/lib/std/array_list.zig
@@ -35,7 +35,7 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {
/// Deinitialize with `deinit` or use `toOwnedSlice`.
pub fn init(allocator: *Allocator) Self {
return Self{
- .items = [_]T{},
+ .items = &[_]T{},
.len = 0,
.allocator = allocator,
};
@@ -306,18 +306,14 @@ test "std.ArrayList.basic" {
testing.expect(list.pop() == 10);
testing.expect(list.len == 9);
- list.appendSlice([_]i32{
- 1,
- 2,
- 3,
- }) catch unreachable;
+ list.appendSlice(&[_]i32{ 1, 2, 3 }) catch unreachable;
testing.expect(list.len == 12);
testing.expect(list.pop() == 3);
testing.expect(list.pop() == 2);
testing.expect(list.pop() == 1);
testing.expect(list.len == 9);
- list.appendSlice([_]i32{}) catch unreachable;
+ list.appendSlice(&[_]i32{}) catch unreachable;
testing.expect(list.len == 9);
// can only set on indices < self.len
@@ -464,10 +460,7 @@ test "std.ArrayList.insertSlice" {
try list.append(2);
try list.append(3);
try list.append(4);
- try list.insertSlice(1, [_]i32{
- 9,
- 8,
- });
+ try list.insertSlice(1, &[_]i32{ 9, 8 });
testing.expect(list.items[0] == 1);
testing.expect(list.items[1] == 9);
testing.expect(list.items[2] == 8);