| author | |
| committer | |
| log | bf3ac6615051143a9ef41180cd74e88de5dd573d |
| tree | 94571f5e6d408287928091c4dad6451d946d6434 |
| parent | 379d547603badb2667089c85454a2e3f5ede3342 |
| signature | Commit is signed but in an unrecognized format. |
* 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.67 files changed, 729 insertions(+), 839 deletions(-)
build.zig+15-15| ... | ... | @@ -20,10 +20,10 @@ pub fn build(b: *Builder) !void { |
| 20 | 20 | const rel_zig_exe = try fs.path.relative(b.allocator, b.build_root, b.zig_exe); |
| 21 | 21 | const langref_out_path = fs.path.join( |
| 22 | 22 | b.allocator, |
| 23 | [_][]const u8{ b.cache_root, "langref.html" }, | |
| 23 | &[_][]const u8{ b.cache_root, "langref.html" }, | |
| 24 | 24 | ) catch unreachable; |
| 25 | 25 | var docgen_cmd = docgen_exe.run(); |
| 26 | docgen_cmd.addArgs([_][]const u8{ | |
| 26 | docgen_cmd.addArgs(&[_][]const u8{ | |
| 27 | 27 | rel_zig_exe, |
| 28 | 28 | "doc" ++ fs.path.sep_str ++ "langref.html.in", |
| 29 | 29 | langref_out_path, |
| ... | ... | @@ -36,7 +36,7 @@ pub fn build(b: *Builder) !void { |
| 36 | 36 | const test_step = b.step("test", "Run all the tests"); |
| 37 | 37 | |
| 38 | 38 | // find the stage0 build artifacts because we're going to re-use config.h and zig_cpp library |
| 39 | const build_info = try b.exec([_][]const u8{ | |
| 39 | const build_info = try b.exec(&[_][]const u8{ | |
| 40 | 40 | b.zig_exe, |
| 41 | 41 | "BUILD_INFO", |
| 42 | 42 | }); |
| ... | ... | @@ -56,7 +56,7 @@ pub fn build(b: *Builder) !void { |
| 56 | 56 | test_stage2.setBuildMode(builtin.Mode.Debug); |
| 57 | 57 | test_stage2.addPackagePath("stage2_tests", "test/stage2/test.zig"); |
| 58 | 58 | |
| 59 | const fmt_build_zig = b.addFmt([_][]const u8{"build.zig"}); | |
| 59 | const fmt_build_zig = b.addFmt(&[_][]const u8{"build.zig"}); | |
| 60 | 60 | |
| 61 | 61 | var exe = b.addExecutable("zig", "src-self-hosted/main.zig"); |
| 62 | 62 | exe.setBuildMode(mode); |
| ... | ... | @@ -88,7 +88,7 @@ pub fn build(b: *Builder) !void { |
| 88 | 88 | .source_dir = "lib", |
| 89 | 89 | .install_dir = .Lib, |
| 90 | 90 | .install_subdir = "zig", |
| 91 | .exclude_extensions = [_][]const u8{ "test.zig", "README.md" }, | |
| 91 | .exclude_extensions = &[_][]const u8{ "test.zig", "README.md" }, | |
| 92 | 92 | }); |
| 93 | 93 | |
| 94 | 94 | const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter"); |
| ... | ... | @@ -148,7 +148,7 @@ fn dependOnLib(b: *Builder, lib_exe_obj: var, dep: LibraryDep) void { |
| 148 | 148 | } |
| 149 | 149 | const lib_dir = fs.path.join( |
| 150 | 150 | b.allocator, |
| 151 | [_][]const u8{ dep.prefix, "lib" }, | |
| 151 | &[_][]const u8{ dep.prefix, "lib" }, | |
| 152 | 152 | ) catch unreachable; |
| 153 | 153 | for (dep.system_libs.toSliceConst()) |lib| { |
| 154 | 154 | const static_bare_name = if (mem.eql(u8, lib, "curses")) |
| ... | ... | @@ -157,7 +157,7 @@ fn dependOnLib(b: *Builder, lib_exe_obj: var, dep: LibraryDep) void { |
| 157 | 157 | b.fmt("lib{}.a", lib); |
| 158 | 158 | const static_lib_name = fs.path.join( |
| 159 | 159 | b.allocator, |
| 160 | [_][]const u8{ lib_dir, static_bare_name }, | |
| 160 | &[_][]const u8{ lib_dir, static_bare_name }, | |
| 161 | 161 | ) catch unreachable; |
| 162 | 162 | const have_static = fileExists(static_lib_name) catch unreachable; |
| 163 | 163 | if (have_static) { |
| ... | ... | @@ -183,7 +183,7 @@ fn fileExists(filename: []const u8) !bool { |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | fn addCppLib(b: *Builder, lib_exe_obj: var, cmake_binary_dir: []const u8, lib_name: []const u8) void { |
| 186 | lib_exe_obj.addObjectFile(fs.path.join(b.allocator, [_][]const u8{ | |
| 186 | lib_exe_obj.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{ | |
| 187 | 187 | cmake_binary_dir, |
| 188 | 188 | "zig_cpp", |
| 189 | 189 | b.fmt("{}{}{}", lib_exe_obj.target.libPrefix(), lib_name, lib_exe_obj.target.staticLibSuffix()), |
| ... | ... | @@ -199,22 +199,22 @@ const LibraryDep = struct { |
| 199 | 199 | }; |
| 200 | 200 | |
| 201 | 201 | fn findLLVM(b: *Builder, llvm_config_exe: []const u8) !LibraryDep { |
| 202 | const shared_mode = try b.exec([_][]const u8{ llvm_config_exe, "--shared-mode" }); | |
| 202 | const shared_mode = try b.exec(&[_][]const u8{ llvm_config_exe, "--shared-mode" }); | |
| 203 | 203 | const is_static = mem.startsWith(u8, shared_mode, "static"); |
| 204 | 204 | const libs_output = if (is_static) |
| 205 | try b.exec([_][]const u8{ | |
| 205 | try b.exec(&[_][]const u8{ | |
| 206 | 206 | llvm_config_exe, |
| 207 | 207 | "--libfiles", |
| 208 | 208 | "--system-libs", |
| 209 | 209 | }) |
| 210 | 210 | else |
| 211 | try b.exec([_][]const u8{ | |
| 211 | try b.exec(&[_][]const u8{ | |
| 212 | 212 | llvm_config_exe, |
| 213 | 213 | "--libs", |
| 214 | 214 | }); |
| 215 | const includes_output = try b.exec([_][]const u8{ llvm_config_exe, "--includedir" }); | |
| 216 | const libdir_output = try b.exec([_][]const u8{ llvm_config_exe, "--libdir" }); | |
| 217 | const prefix_output = try b.exec([_][]const u8{ llvm_config_exe, "--prefix" }); | |
| 215 | const includes_output = try b.exec(&[_][]const u8{ llvm_config_exe, "--includedir" }); | |
| 216 | const libdir_output = try b.exec(&[_][]const u8{ llvm_config_exe, "--libdir" }); | |
| 217 | const prefix_output = try b.exec(&[_][]const u8{ llvm_config_exe, "--prefix" }); | |
| 218 | 218 | |
| 219 | 219 | var result = LibraryDep{ |
| 220 | 220 | .prefix = mem.tokenize(prefix_output, " \r\n").next().?, |
| ... | ... | @@ -341,7 +341,7 @@ fn addCxxKnownPath( |
| 341 | 341 | objname: []const u8, |
| 342 | 342 | errtxt: ?[]const u8, |
| 343 | 343 | ) !void { |
| 344 | const path_padded = try b.exec([_][]const u8{ | |
| 344 | const path_padded = try b.exec(&[_][]const u8{ | |
| 345 | 345 | ctx.cxx_compiler, |
| 346 | 346 | b.fmt("-print-file-name={}", objname), |
| 347 | 347 | }); |
lib/std/array_list.zig+4-11| ... | ... | @@ -35,7 +35,7 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type { |
| 35 | 35 | /// Deinitialize with `deinit` or use `toOwnedSlice`. |
| 36 | 36 | pub fn init(allocator: *Allocator) Self { |
| 37 | 37 | return Self{ |
| 38 | .items = [_]T{}, | |
| 38 | .items = &[_]T{}, | |
| 39 | 39 | .len = 0, |
| 40 | 40 | .allocator = allocator, |
| 41 | 41 | }; |
| ... | ... | @@ -306,18 +306,14 @@ test "std.ArrayList.basic" { |
| 306 | 306 | testing.expect(list.pop() == 10); |
| 307 | 307 | testing.expect(list.len == 9); |
| 308 | 308 | |
| 309 | list.appendSlice([_]i32{ | |
| 310 | 1, | |
| 311 | 2, | |
| 312 | 3, | |
| 313 | }) catch unreachable; | |
| 309 | list.appendSlice(&[_]i32{ 1, 2, 3 }) catch unreachable; | |
| 314 | 310 | testing.expect(list.len == 12); |
| 315 | 311 | testing.expect(list.pop() == 3); |
| 316 | 312 | testing.expect(list.pop() == 2); |
| 317 | 313 | testing.expect(list.pop() == 1); |
| 318 | 314 | testing.expect(list.len == 9); |
| 319 | 315 | |
| 320 | list.appendSlice([_]i32{}) catch unreachable; | |
| 316 | list.appendSlice(&[_]i32{}) catch unreachable; | |
| 321 | 317 | testing.expect(list.len == 9); |
| 322 | 318 | |
| 323 | 319 | // can only set on indices < self.len |
| ... | ... | @@ -464,10 +460,7 @@ test "std.ArrayList.insertSlice" { |
| 464 | 460 | try list.append(2); |
| 465 | 461 | try list.append(3); |
| 466 | 462 | try list.append(4); |
| 467 | try list.insertSlice(1, [_]i32{ | |
| 468 | 9, | |
| 469 | 8, | |
| 470 | }); | |
| 463 | try list.insertSlice(1, &[_]i32{ 9, 8 }); | |
| 471 | 464 | testing.expect(list.items[0] == 1); |
| 472 | 465 | testing.expect(list.items[1] == 9); |
| 473 | 466 | testing.expect(list.items[2] == 8); |
lib/std/bloom_filter.zig+3-3| ... | ... | @@ -62,7 +62,7 @@ pub fn BloomFilter( |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | pub fn getCell(self: Self, cell: Index) Cell { |
| 65 | return Io.get(self.data, cell, 0); | |
| 65 | return Io.get(&self.data, cell, 0); | |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | pub fn incrementCell(self: *Self, cell: Index) void { |
| ... | ... | @@ -70,7 +70,7 @@ pub fn BloomFilter( |
| 70 | 70 | // skip the 'get' operation |
| 71 | 71 | Io.set(&self.data, cell, 0, cellMax); |
| 72 | 72 | } else { |
| 73 | const old = Io.get(self.data, cell, 0); | |
| 73 | const old = Io.get(&self.data, cell, 0); | |
| 74 | 74 | if (old != cellMax) { |
| 75 | 75 | Io.set(&self.data, cell, 0, old + 1); |
| 76 | 76 | } |
| ... | ... | @@ -120,7 +120,7 @@ pub fn BloomFilter( |
| 120 | 120 | } else if (newsize > n_items) { |
| 121 | 121 | var copied: usize = 0; |
| 122 | 122 | while (copied < r.data.len) : (copied += self.data.len) { |
| 123 | std.mem.copy(u8, r.data[copied .. copied + self.data.len], self.data); | |
| 123 | std.mem.copy(u8, r.data[copied .. copied + self.data.len], &self.data); | |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | return r; |
lib/std/build.zig+30-27| ... | ... | @@ -186,7 +186,7 @@ pub const Builder = struct { |
| 186 | 186 | pub fn resolveInstallPrefix(self: *Builder) void { |
| 187 | 187 | if (self.dest_dir) |dest_dir| { |
| 188 | 188 | const install_prefix = self.install_prefix orelse "/usr"; |
| 189 | self.install_path = fs.path.join(self.allocator, [_][]const u8{ dest_dir, install_prefix }) catch unreachable; | |
| 189 | self.install_path = fs.path.join(self.allocator, &[_][]const u8{ dest_dir, install_prefix }) catch unreachable; | |
| 190 | 190 | } else { |
| 191 | 191 | const install_prefix = self.install_prefix orelse blk: { |
| 192 | 192 | const p = self.cache_root; |
| ... | ... | @@ -195,8 +195,8 @@ pub const Builder = struct { |
| 195 | 195 | }; |
| 196 | 196 | self.install_path = install_prefix; |
| 197 | 197 | } |
| 198 | self.lib_dir = fs.path.join(self.allocator, [_][]const u8{ self.install_path, "lib" }) catch unreachable; | |
| 199 | self.exe_dir = fs.path.join(self.allocator, [_][]const u8{ self.install_path, "bin" }) catch unreachable; | |
| 198 | self.lib_dir = fs.path.join(self.allocator, &[_][]const u8{ self.install_path, "lib" }) catch unreachable; | |
| 199 | self.exe_dir = fs.path.join(self.allocator, &[_][]const u8{ self.install_path, "bin" }) catch unreachable; | |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | pub fn addExecutable(self: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep { |
| ... | ... | @@ -803,7 +803,7 @@ pub const Builder = struct { |
| 803 | 803 | } |
| 804 | 804 | |
| 805 | 805 | fn pathFromRoot(self: *Builder, rel_path: []const u8) []u8 { |
| 806 | return fs.path.resolve(self.allocator, [_][]const u8{ self.build_root, rel_path }) catch unreachable; | |
| 806 | return fs.path.resolve(self.allocator, &[_][]const u8{ self.build_root, rel_path }) catch unreachable; | |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | pub fn fmt(self: *Builder, comptime format: []const u8, args: ...) []u8 { |
| ... | ... | @@ -818,7 +818,7 @@ pub const Builder = struct { |
| 818 | 818 | if (fs.path.isAbsolute(name)) { |
| 819 | 819 | return name; |
| 820 | 820 | } |
| 821 | const full_path = try fs.path.join(self.allocator, [_][]const u8{ search_prefix, "bin", self.fmt("{}{}", name, exe_extension) }); | |
| 821 | const full_path = try fs.path.join(self.allocator, &[_][]const u8{ search_prefix, "bin", self.fmt("{}{}", name, exe_extension) }); | |
| 822 | 822 | return fs.realpathAlloc(self.allocator, full_path) catch continue; |
| 823 | 823 | } |
| 824 | 824 | } |
| ... | ... | @@ -827,9 +827,9 @@ pub const Builder = struct { |
| 827 | 827 | if (fs.path.isAbsolute(name)) { |
| 828 | 828 | return name; |
| 829 | 829 | } |
| 830 | var it = mem.tokenize(PATH, [_]u8{fs.path.delimiter}); | |
| 830 | var it = mem.tokenize(PATH, &[_]u8{fs.path.delimiter}); | |
| 831 | 831 | while (it.next()) |path| { |
| 832 | const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) }); | |
| 832 | const full_path = try fs.path.join(self.allocator, &[_][]const u8{ path, self.fmt("{}{}", name, exe_extension) }); | |
| 833 | 833 | return fs.realpathAlloc(self.allocator, full_path) catch continue; |
| 834 | 834 | } |
| 835 | 835 | } |
| ... | ... | @@ -839,7 +839,7 @@ pub const Builder = struct { |
| 839 | 839 | return name; |
| 840 | 840 | } |
| 841 | 841 | for (paths) |path| { |
| 842 | const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) }); | |
| 842 | const full_path = try fs.path.join(self.allocator, &[_][]const u8{ path, self.fmt("{}{}", name, exe_extension) }); | |
| 843 | 843 | return fs.realpathAlloc(self.allocator, full_path) catch continue; |
| 844 | 844 | } |
| 845 | 845 | } |
| ... | ... | @@ -926,12 +926,12 @@ pub const Builder = struct { |
| 926 | 926 | }; |
| 927 | 927 | return fs.path.resolve( |
| 928 | 928 | self.allocator, |
| 929 | [_][]const u8{ base_dir, dest_rel_path }, | |
| 929 | &[_][]const u8{ base_dir, dest_rel_path }, | |
| 930 | 930 | ) catch unreachable; |
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | fn execPkgConfigList(self: *Builder, out_code: *u8) ![]const PkgConfigPkg { |
| 934 | const stdout = try self.execAllowFail([_][]const u8{ "pkg-config", "--list-all" }, out_code, .Ignore); | |
| 934 | const stdout = try self.execAllowFail(&[_][]const u8{ "pkg-config", "--list-all" }, out_code, .Ignore); | |
| 935 | 935 | var list = ArrayList(PkgConfigPkg).init(self.allocator); |
| 936 | 936 | var line_it = mem.tokenize(stdout, "\r\n"); |
| 937 | 937 | while (line_it.next()) |line| { |
| ... | ... | @@ -970,7 +970,7 @@ pub const Builder = struct { |
| 970 | 970 | |
| 971 | 971 | test "builder.findProgram compiles" { |
| 972 | 972 | const builder = try Builder.create(std.heap.page_allocator, "zig", "zig-cache", "zig-cache"); |
| 973 | _ = builder.findProgram([_][]const u8{}, [_][]const u8{}) catch null; | |
| 973 | _ = builder.findProgram(&[_][]const u8{}, &[_][]const u8{}) catch null; | |
| 974 | 974 | } |
| 975 | 975 | |
| 976 | 976 | /// Deprecated. Use `builtin.Version`. |
| ... | ... | @@ -1384,7 +1384,7 @@ pub const LibExeObjStep = struct { |
| 1384 | 1384 | }; |
| 1385 | 1385 | |
| 1386 | 1386 | var code: u8 = undefined; |
| 1387 | const stdout = if (self.builder.execAllowFail([_][]const u8{ | |
| 1387 | const stdout = if (self.builder.execAllowFail(&[_][]const u8{ | |
| 1388 | 1388 | "pkg-config", |
| 1389 | 1389 | pkg_name, |
| 1390 | 1390 | "--cflags", |
| ... | ... | @@ -1504,7 +1504,7 @@ pub const LibExeObjStep = struct { |
| 1504 | 1504 | pub fn getOutputPath(self: *LibExeObjStep) []const u8 { |
| 1505 | 1505 | return fs.path.join( |
| 1506 | 1506 | self.builder.allocator, |
| 1507 | [_][]const u8{ self.output_dir.?, self.out_filename }, | |
| 1507 | &[_][]const u8{ self.output_dir.?, self.out_filename }, | |
| 1508 | 1508 | ) catch unreachable; |
| 1509 | 1509 | } |
| 1510 | 1510 | |
| ... | ... | @@ -1514,7 +1514,7 @@ pub const LibExeObjStep = struct { |
| 1514 | 1514 | assert(self.kind == Kind.Lib); |
| 1515 | 1515 | return fs.path.join( |
| 1516 | 1516 | self.builder.allocator, |
| 1517 | [_][]const u8{ self.output_dir.?, self.out_lib_filename }, | |
| 1517 | &[_][]const u8{ self.output_dir.?, self.out_lib_filename }, | |
| 1518 | 1518 | ) catch unreachable; |
| 1519 | 1519 | } |
| 1520 | 1520 | |
| ... | ... | @@ -1525,7 +1525,7 @@ pub const LibExeObjStep = struct { |
| 1525 | 1525 | assert(!self.disable_gen_h); |
| 1526 | 1526 | return fs.path.join( |
| 1527 | 1527 | self.builder.allocator, |
| 1528 | [_][]const u8{ self.output_dir.?, self.out_h_filename }, | |
| 1528 | &[_][]const u8{ self.output_dir.?, self.out_h_filename }, | |
| 1529 | 1529 | ) catch unreachable; |
| 1530 | 1530 | } |
| 1531 | 1531 | |
| ... | ... | @@ -1535,7 +1535,7 @@ pub const LibExeObjStep = struct { |
| 1535 | 1535 | assert(self.target.isWindows() or self.target.isUefi()); |
| 1536 | 1536 | return fs.path.join( |
| 1537 | 1537 | self.builder.allocator, |
| 1538 | [_][]const u8{ self.output_dir.?, self.out_pdb_filename }, | |
| 1538 | &[_][]const u8{ self.output_dir.?, self.out_pdb_filename }, | |
| 1539 | 1539 | ) catch unreachable; |
| 1540 | 1540 | } |
| 1541 | 1541 | |
| ... | ... | @@ -1605,14 +1605,14 @@ pub const LibExeObjStep = struct { |
| 1605 | 1605 | const triplet = try Target.vcpkgTriplet(allocator, self.target, linkage); |
| 1606 | 1606 | defer self.builder.allocator.free(triplet); |
| 1607 | 1607 | |
| 1608 | const include_path = try fs.path.join(allocator, [_][]const u8{ root, "installed", triplet, "include" }); | |
| 1608 | const include_path = try fs.path.join(allocator, &[_][]const u8{ root, "installed", triplet, "include" }); | |
| 1609 | 1609 | errdefer allocator.free(include_path); |
| 1610 | 1610 | try self.include_dirs.append(IncludeDir{ .RawPath = include_path }); |
| 1611 | 1611 | |
| 1612 | const lib_path = try fs.path.join(allocator, [_][]const u8{ root, "installed", triplet, "lib" }); | |
| 1612 | const lib_path = try fs.path.join(allocator, &[_][]const u8{ root, "installed", triplet, "lib" }); | |
| 1613 | 1613 | try self.lib_paths.append(lib_path); |
| 1614 | 1614 | |
| 1615 | self.vcpkg_bin_path = try fs.path.join(allocator, [_][]const u8{ root, "installed", triplet, "bin" }); | |
| 1615 | self.vcpkg_bin_path = try fs.path.join(allocator, &[_][]const u8{ root, "installed", triplet, "bin" }); | |
| 1616 | 1616 | }, |
| 1617 | 1617 | } |
| 1618 | 1618 | } |
| ... | ... | @@ -1725,7 +1725,7 @@ pub const LibExeObjStep = struct { |
| 1725 | 1725 | if (self.build_options_contents.len() > 0) { |
| 1726 | 1726 | const build_options_file = try fs.path.join( |
| 1727 | 1727 | builder.allocator, |
| 1728 | [_][]const u8{ builder.cache_root, builder.fmt("{}_build_options.zig", self.name) }, | |
| 1728 | &[_][]const u8{ builder.cache_root, builder.fmt("{}_build_options.zig", self.name) }, | |
| 1729 | 1729 | ); |
| 1730 | 1730 | try std.io.writeFile(build_options_file, self.build_options_contents.toSliceConst()); |
| 1731 | 1731 | try zig_args.append("--pkg-begin"); |
| ... | ... | @@ -1849,7 +1849,7 @@ pub const LibExeObjStep = struct { |
| 1849 | 1849 | try zig_args.append("--test-cmd"); |
| 1850 | 1850 | try zig_args.append(bin_name); |
| 1851 | 1851 | if (glibc_dir_arg) |dir| { |
| 1852 | const full_dir = try fs.path.join(builder.allocator, [_][]const u8{ | |
| 1852 | const full_dir = try fs.path.join(builder.allocator, &[_][]const u8{ | |
| 1853 | 1853 | dir, |
| 1854 | 1854 | try self.target.linuxTriple(builder.allocator), |
| 1855 | 1855 | }); |
| ... | ... | @@ -1994,7 +1994,7 @@ pub const LibExeObjStep = struct { |
| 1994 | 1994 | const output_path = mem.trimRight(u8, output_path_nl, "\r\n"); |
| 1995 | 1995 | |
| 1996 | 1996 | if (self.output_dir) |output_dir| { |
| 1997 | const full_dest = try fs.path.join(builder.allocator, [_][]const u8{ | |
| 1997 | const full_dest = try fs.path.join(builder.allocator, &[_][]const u8{ | |
| 1998 | 1998 | output_dir, |
| 1999 | 1999 | fs.path.basename(output_path), |
| 2000 | 2000 | }); |
| ... | ... | @@ -2068,7 +2068,7 @@ pub const RunStep = struct { |
| 2068 | 2068 | env_map.set(PATH, search_path) catch unreachable; |
| 2069 | 2069 | return; |
| 2070 | 2070 | }; |
| 2071 | const new_path = self.builder.fmt("{}" ++ [1]u8{fs.path.delimiter} ++ "{}", prev_path, search_path); | |
| 2071 | const new_path = self.builder.fmt("{}" ++ &[1]u8{fs.path.delimiter} ++ "{}", prev_path, search_path); | |
| 2072 | 2072 | env_map.set(PATH, new_path) catch unreachable; |
| 2073 | 2073 | } |
| 2074 | 2074 | |
| ... | ... | @@ -2162,6 +2162,9 @@ const InstallArtifactStep = struct { |
| 2162 | 2162 | if (self.artifact.isDynamicLibrary()) { |
| 2163 | 2163 | builder.pushInstalledFile(.Lib, artifact.major_only_filename); |
| 2164 | 2164 | builder.pushInstalledFile(.Lib, artifact.name_only_filename); |
| 2165 | if (self.artifact.target.isWindows()) { | |
| 2166 | builder.pushInstalledFile(.Lib, artifact.out_lib_filename); | |
| 2167 | } | |
| 2165 | 2168 | } |
| 2166 | 2169 | if (self.pdb_dir) |pdb_dir| { |
| 2167 | 2170 | builder.pushInstalledFile(pdb_dir, artifact.out_pdb_filename); |
| ... | ... | @@ -2254,7 +2257,7 @@ pub const InstallDirStep = struct { |
| 2254 | 2257 | }; |
| 2255 | 2258 | |
| 2256 | 2259 | const rel_path = entry.path[full_src_dir.len + 1 ..]; |
| 2257 | const dest_path = try fs.path.join(self.builder.allocator, [_][]const u8{ dest_prefix, rel_path }); | |
| 2260 | const dest_path = try fs.path.join(self.builder.allocator, &[_][]const u8{ dest_prefix, rel_path }); | |
| 2258 | 2261 | switch (entry.kind) { |
| 2259 | 2262 | .Directory => try fs.makePath(self.builder.allocator, dest_path), |
| 2260 | 2263 | .File => try self.builder.updateFile(entry.path, dest_path), |
| ... | ... | @@ -2377,7 +2380,7 @@ fn doAtomicSymLinks(allocator: *Allocator, output_path: []const u8, filename_maj |
| 2377 | 2380 | // sym link for libfoo.so.1 to libfoo.so.1.2.3 |
| 2378 | 2381 | const major_only_path = fs.path.join( |
| 2379 | 2382 | allocator, |
| 2380 | [_][]const u8{ out_dir, filename_major_only }, | |
| 2383 | &[_][]const u8{ out_dir, filename_major_only }, | |
| 2381 | 2384 | ) catch unreachable; |
| 2382 | 2385 | fs.atomicSymLink(allocator, out_basename, major_only_path) catch |err| { |
| 2383 | 2386 | warn("Unable to symlink {} -> {}\n", major_only_path, out_basename); |
| ... | ... | @@ -2386,7 +2389,7 @@ fn doAtomicSymLinks(allocator: *Allocator, output_path: []const u8, filename_maj |
| 2386 | 2389 | // sym link for libfoo.so to libfoo.so.1 |
| 2387 | 2390 | const name_only_path = fs.path.join( |
| 2388 | 2391 | allocator, |
| 2389 | [_][]const u8{ out_dir, filename_name_only }, | |
| 2392 | &[_][]const u8{ out_dir, filename_name_only }, | |
| 2390 | 2393 | ) catch unreachable; |
| 2391 | 2394 | fs.atomicSymLink(allocator, filename_major_only, name_only_path) catch |err| { |
| 2392 | 2395 | warn("Unable to symlink {} -> {}\n", name_only_path, filename_major_only); |
| ... | ... | @@ -2399,7 +2402,7 @@ fn findVcpkgRoot(allocator: *Allocator) !?[]const u8 { |
| 2399 | 2402 | const appdata_path = try fs.getAppDataDir(allocator, "vcpkg"); |
| 2400 | 2403 | defer allocator.free(appdata_path); |
| 2401 | 2404 | |
| 2402 | const path_file = try fs.path.join(allocator, [_][]const u8{ appdata_path, "vcpkg.path.txt" }); | |
| 2405 | const path_file = try fs.path.join(allocator, &[_][]const u8{ appdata_path, "vcpkg.path.txt" }); | |
| 2403 | 2406 | defer allocator.free(path_file); |
| 2404 | 2407 | |
| 2405 | 2408 | const file = fs.File.openRead(path_file) catch return null; |
lib/std/crypto/aes.zig+2-2| ... | ... | @@ -136,7 +136,7 @@ fn AES(comptime keysize: usize) type { |
| 136 | 136 | |
| 137 | 137 | pub fn init(key: [keysize / 8]u8) Self { |
| 138 | 138 | var ctx: Self = undefined; |
| 139 | expandKey(key, ctx.enc[0..], ctx.dec[0..]); | |
| 139 | expandKey(&key, ctx.enc[0..], ctx.dec[0..]); | |
| 140 | 140 | return ctx; |
| 141 | 141 | } |
| 142 | 142 | |
| ... | ... | @@ -157,7 +157,7 @@ fn AES(comptime keysize: usize) type { |
| 157 | 157 | var ctr_i = std.mem.readIntSliceBig(u128, ctrbuf[0..]); |
| 158 | 158 | std.mem.writeIntSliceBig(u128, ctrbuf[0..], ctr_i +% 1); |
| 159 | 159 | |
| 160 | n += xorBytes(dst[n..], src[n..], keystream); | |
| 160 | n += xorBytes(dst[n..], src[n..], &keystream); | |
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | }; |
lib/std/crypto/blake2.zig+2-2| ... | ... | @@ -256,7 +256,7 @@ test "blake2s256 aligned final" { |
| 256 | 256 | var out: [Blake2s256.digest_length]u8 = undefined; |
| 257 | 257 | |
| 258 | 258 | var h = Blake2s256.init(); |
| 259 | h.update(block); | |
| 259 | h.update(&block); | |
| 260 | 260 | h.final(out[0..]); |
| 261 | 261 | } |
| 262 | 262 | |
| ... | ... | @@ -490,6 +490,6 @@ test "blake2b512 aligned final" { |
| 490 | 490 | var out: [Blake2b512.digest_length]u8 = undefined; |
| 491 | 491 | |
| 492 | 492 | var h = Blake2b512.init(); |
| 493 | h.update(block); | |
| 493 | h.update(&block); | |
| 494 | 494 | h.final(out[0..]); |
| 495 | 495 | } |
lib/std/crypto/chacha20.zig+7-7| ... | ... | @@ -218,12 +218,12 @@ test "crypto.chacha20 test vector sunscreen" { |
| 218 | 218 | }; |
| 219 | 219 | |
| 220 | 220 | chaCha20IETF(result[0..], input[0..], 1, key, nonce); |
| 221 | testing.expectEqualSlices(u8, expected_result, result); | |
| 221 | testing.expectEqualSlices(u8, &expected_result, &result); | |
| 222 | 222 | |
| 223 | 223 | // Chacha20 is self-reversing. |
| 224 | 224 | var plaintext: [114]u8 = undefined; |
| 225 | 225 | chaCha20IETF(plaintext[0..], result[0..], 1, key, nonce); |
| 226 | testing.expect(mem.compare(u8, input, plaintext) == mem.Compare.Equal); | |
| 226 | testing.expect(mem.compare(u8, input, &plaintext) == mem.Compare.Equal); | |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | // https://tools.ietf.org/html/draft-agl-tls-chacha20poly1305-04#section-7 |
| ... | ... | @@ -258,7 +258,7 @@ test "crypto.chacha20 test vector 1" { |
| 258 | 258 | const nonce = [_]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 259 | 259 | |
| 260 | 260 | chaCha20With64BitNonce(result[0..], input[0..], 0, key, nonce); |
| 261 | testing.expectEqualSlices(u8, expected_result, result); | |
| 261 | testing.expectEqualSlices(u8, &expected_result, &result); | |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | test "crypto.chacha20 test vector 2" { |
| ... | ... | @@ -292,7 +292,7 @@ test "crypto.chacha20 test vector 2" { |
| 292 | 292 | const nonce = [_]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 293 | 293 | |
| 294 | 294 | chaCha20With64BitNonce(result[0..], input[0..], 0, key, nonce); |
| 295 | testing.expectEqualSlices(u8, expected_result, result); | |
| 295 | testing.expectEqualSlices(u8, &expected_result, &result); | |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | test "crypto.chacha20 test vector 3" { |
| ... | ... | @@ -326,7 +326,7 @@ test "crypto.chacha20 test vector 3" { |
| 326 | 326 | const nonce = [_]u8{ 0, 0, 0, 0, 0, 0, 0, 1 }; |
| 327 | 327 | |
| 328 | 328 | chaCha20With64BitNonce(result[0..], input[0..], 0, key, nonce); |
| 329 | testing.expectEqualSlices(u8, expected_result, result); | |
| 329 | testing.expectEqualSlices(u8, &expected_result, &result); | |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | test "crypto.chacha20 test vector 4" { |
| ... | ... | @@ -360,7 +360,7 @@ test "crypto.chacha20 test vector 4" { |
| 360 | 360 | const nonce = [_]u8{ 1, 0, 0, 0, 0, 0, 0, 0 }; |
| 361 | 361 | |
| 362 | 362 | chaCha20With64BitNonce(result[0..], input[0..], 0, key, nonce); |
| 363 | testing.expectEqualSlices(u8, expected_result, result); | |
| 363 | testing.expectEqualSlices(u8, &expected_result, &result); | |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | test "crypto.chacha20 test vector 5" { |
| ... | ... | @@ -432,5 +432,5 @@ test "crypto.chacha20 test vector 5" { |
| 432 | 432 | }; |
| 433 | 433 | |
| 434 | 434 | chaCha20With64BitNonce(result[0..], input[0..], 0, key, nonce); |
| 435 | testing.expectEqualSlices(u8, expected_result, result); | |
| 435 | testing.expectEqualSlices(u8, &expected_result, &result); | |
| 436 | 436 | } |
lib/std/crypto/gimli.zig+4-4| ... | ... | @@ -83,7 +83,7 @@ test "permute" { |
| 83 | 83 | while (i < 12) : (i += 1) { |
| 84 | 84 | input[i] = i * i * i + i *% 0x9e3779b9; |
| 85 | 85 | } |
| 86 | testing.expectEqualSlices(u32, input, [_]u32{ | |
| 86 | testing.expectEqualSlices(u32, &input, &[_]u32{ | |
| 87 | 87 | 0x00000000, 0x9e3779ba, 0x3c6ef37a, 0xdaa66d46, |
| 88 | 88 | 0x78dde724, 0x1715611a, 0xb54cdb2e, 0x53845566, |
| 89 | 89 | 0xf1bbcfc8, 0x8ff34a5a, 0x2e2ac522, 0xcc624026, |
| ... | ... | @@ -92,7 +92,7 @@ test "permute" { |
| 92 | 92 | }, |
| 93 | 93 | }; |
| 94 | 94 | state.permute(); |
| 95 | testing.expectEqualSlices(u32, state.data, [_]u32{ | |
| 95 | testing.expectEqualSlices(u32, &state.data, &[_]u32{ | |
| 96 | 96 | 0xba11c85a, 0x91bad119, 0x380ce880, 0xd24c2c68, |
| 97 | 97 | 0x3eceffea, 0x277a921c, 0x4f73a0bd, 0xda5a9cd8, |
| 98 | 98 | 0x84b673f0, 0x34e52ff7, 0x9e2bef49, 0xf41bb8d6, |
| ... | ... | @@ -163,6 +163,6 @@ test "hash" { |
| 163 | 163 | var msg: [58 / 2]u8 = undefined; |
| 164 | 164 | try std.fmt.hexToBytes(&msg, "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C"); |
| 165 | 165 | var md: [32]u8 = undefined; |
| 166 | hash(&md, msg); | |
| 167 | htest.assertEqual("1C9A03DC6A5DDC5444CFC6F4B154CFF5CF081633B2CEA4D7D0AE7CCFED5AAA44", md); | |
| 166 | hash(&md, &msg); | |
| 167 | htest.assertEqual("1C9A03DC6A5DDC5444CFC6F4B154CFF5CF081633B2CEA4D7D0AE7CCFED5AAA44", &md); | |
| 168 | 168 | } |
lib/std/crypto/md5.zig+1-1| ... | ... | @@ -276,6 +276,6 @@ test "md5 aligned final" { |
| 276 | 276 | var out: [Md5.digest_length]u8 = undefined; |
| 277 | 277 | |
| 278 | 278 | var h = Md5.init(); |
| 279 | h.update(block); | |
| 279 | h.update(&block); | |
| 280 | 280 | h.final(out[0..]); |
| 281 | 281 | } |
lib/std/crypto/poly1305.zig+1-1| ... | ... | @@ -230,5 +230,5 @@ test "poly1305 rfc7439 vector1" { |
| 230 | 230 | var mac: [16]u8 = undefined; |
| 231 | 231 | Poly1305.create(mac[0..], msg, key); |
| 232 | 232 | |
| 233 | std.testing.expectEqualSlices(u8, expected_mac, mac); | |
| 233 | std.testing.expectEqualSlices(u8, expected_mac, &mac); | |
| 234 | 234 | } |
lib/std/crypto/sha1.zig+1-1| ... | ... | @@ -297,6 +297,6 @@ test "sha1 aligned final" { |
| 297 | 297 | var out: [Sha1.digest_length]u8 = undefined; |
| 298 | 298 | |
| 299 | 299 | var h = Sha1.init(); |
| 300 | h.update(block); | |
| 300 | h.update(&block); | |
| 301 | 301 | h.final(out[0..]); |
| 302 | 302 | } |
lib/std/crypto/sha2.zig+2-2| ... | ... | @@ -343,7 +343,7 @@ test "sha256 aligned final" { |
| 343 | 343 | var out: [Sha256.digest_length]u8 = undefined; |
| 344 | 344 | |
| 345 | 345 | var h = Sha256.init(); |
| 346 | h.update(block); | |
| 346 | h.update(&block); | |
| 347 | 347 | h.final(out[0..]); |
| 348 | 348 | } |
| 349 | 349 | |
| ... | ... | @@ -723,6 +723,6 @@ test "sha512 aligned final" { |
| 723 | 723 | var out: [Sha512.digest_length]u8 = undefined; |
| 724 | 724 | |
| 725 | 725 | var h = Sha512.init(); |
| 726 | h.update(block); | |
| 726 | h.update(&block); | |
| 727 | 727 | h.final(out[0..]); |
| 728 | 728 | } |
lib/std/crypto/sha3.zig+2-2| ... | ... | @@ -229,7 +229,7 @@ test "sha3-256 aligned final" { |
| 229 | 229 | var out: [Sha3_256.digest_length]u8 = undefined; |
| 230 | 230 | |
| 231 | 231 | var h = Sha3_256.init(); |
| 232 | h.update(block); | |
| 232 | h.update(&block); | |
| 233 | 233 | h.final(out[0..]); |
| 234 | 234 | } |
| 235 | 235 | |
| ... | ... | @@ -300,6 +300,6 @@ test "sha3-512 aligned final" { |
| 300 | 300 | var out: [Sha3_512.digest_length]u8 = undefined; |
| 301 | 301 | |
| 302 | 302 | var h = Sha3_512.init(); |
| 303 | h.update(block); | |
| 303 | h.update(&block); | |
| 304 | 304 | h.final(out[0..]); |
| 305 | 305 | } |
lib/std/crypto/test.zig+2-2| ... | ... | @@ -8,7 +8,7 @@ pub fn assertEqualHash(comptime Hasher: var, comptime expected: []const u8, inpu |
| 8 | 8 | var h: [expected.len / 2]u8 = undefined; |
| 9 | 9 | Hasher.hash(input, h[0..]); |
| 10 | 10 | |
| 11 | assertEqual(expected, h); | |
| 11 | assertEqual(expected, &h); | |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // Assert `expected` == `input` where `input` is a bytestring. |
| ... | ... | @@ -18,5 +18,5 @@ pub fn assertEqual(comptime expected: []const u8, input: []const u8) void { |
| 18 | 18 | r.* = fmt.parseInt(u8, expected[2 * i .. 2 * i + 2], 16) catch unreachable; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | testing.expectEqualSlices(u8, expected_bytes, input); | |
| 21 | testing.expectEqualSlices(u8, &expected_bytes, input); | |
| 22 | 22 | } |
lib/std/crypto/x25519.zig+18-18| ... | ... | @@ -63,7 +63,7 @@ pub const X25519 = struct { |
| 63 | 63 | var pos: isize = 254; |
| 64 | 64 | while (pos >= 0) : (pos -= 1) { |
| 65 | 65 | // constant time conditional swap before ladder step |
| 66 | const b = scalarBit(e, @intCast(usize, pos)); | |
| 66 | const b = scalarBit(&e, @intCast(usize, pos)); | |
| 67 | 67 | swap ^= b; // xor trick avoids swapping at the end of the loop |
| 68 | 68 | Fe.cswap(x2, x3, swap); |
| 69 | 69 | Fe.cswap(z2, z3, swap); |
| ... | ... | @@ -117,7 +117,7 @@ pub const X25519 = struct { |
| 117 | 117 | |
| 118 | 118 | pub fn createPublicKey(public_key: []u8, private_key: []const u8) bool { |
| 119 | 119 | var base_point = [_]u8{9} ++ [_]u8{0} ** 31; |
| 120 | return create(public_key, private_key, base_point); | |
| 120 | return create(public_key, private_key, &base_point); | |
| 121 | 121 | } |
| 122 | 122 | }; |
| 123 | 123 | |
| ... | ... | @@ -581,8 +581,8 @@ test "x25519 public key calculation from secret key" { |
| 581 | 581 | var pk_calculated: [32]u8 = undefined; |
| 582 | 582 | try fmt.hexToBytes(sk[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166"); |
| 583 | 583 | try fmt.hexToBytes(pk_expected[0..], "f1814f0e8ff1043d8a44d25babff3cedcae6c22c3edaa48f857ae70de2baae50"); |
| 584 | std.testing.expect(X25519.createPublicKey(pk_calculated[0..], sk)); | |
| 585 | std.testing.expect(std.mem.eql(u8, pk_calculated, pk_expected)); | |
| 584 | std.testing.expect(X25519.createPublicKey(pk_calculated[0..], &sk)); | |
| 585 | std.testing.expect(std.mem.eql(u8, &pk_calculated, &pk_expected)); | |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | test "x25519 rfc7748 vector1" { |
| ... | ... | @@ -594,7 +594,7 @@ test "x25519 rfc7748 vector1" { |
| 594 | 594 | var output: [32]u8 = undefined; |
| 595 | 595 | |
| 596 | 596 | std.testing.expect(X25519.create(output[0..], secret_key, public_key)); |
| 597 | std.testing.expect(std.mem.eql(u8, output, expected_output)); | |
| 597 | std.testing.expect(std.mem.eql(u8, &output, expected_output)); | |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | test "x25519 rfc7748 vector2" { |
| ... | ... | @@ -606,12 +606,12 @@ test "x25519 rfc7748 vector2" { |
| 606 | 606 | var output: [32]u8 = undefined; |
| 607 | 607 | |
| 608 | 608 | std.testing.expect(X25519.create(output[0..], secret_key, public_key)); |
| 609 | std.testing.expect(std.mem.eql(u8, output, expected_output)); | |
| 609 | std.testing.expect(std.mem.eql(u8, &output, expected_output)); | |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | test "x25519 rfc7748 one iteration" { |
| 613 | 613 | const initial_value = "\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00".*; |
| 614 | const expected_output = "\x42\x2c\x8e\x7a\x62\x27\xd7\xbc\xa1\x35\x0b\x3e\x2b\xb7\x27\x9f\x78\x97\xb8\x7b\xb6\x85\x4b\x78\x3c\x60\xe8\x03\x11\xae\x30\x79".*; | |
| 614 | const expected_output = "\x42\x2c\x8e\x7a\x62\x27\xd7\xbc\xa1\x35\x0b\x3e\x2b\xb7\x27\x9f\x78\x97\xb8\x7b\xb6\x85\x4b\x78\x3c\x60\xe8\x03\x11\xae\x30\x79"; | |
| 615 | 615 | |
| 616 | 616 | var k: [32]u8 = initial_value; |
| 617 | 617 | var u: [32]u8 = initial_value; |
| ... | ... | @@ -619,7 +619,7 @@ test "x25519 rfc7748 one iteration" { |
| 619 | 619 | var i: usize = 0; |
| 620 | 620 | while (i < 1) : (i += 1) { |
| 621 | 621 | var output: [32]u8 = undefined; |
| 622 | std.testing.expect(X25519.create(output[0..], k, u)); | |
| 622 | std.testing.expect(X25519.create(output[0..], &k, &u)); | |
| 623 | 623 | |
| 624 | 624 | std.mem.copy(u8, u[0..], k[0..]); |
| 625 | 625 | std.mem.copy(u8, k[0..], output[0..]); |
| ... | ... | @@ -634,16 +634,16 @@ test "x25519 rfc7748 1,000 iterations" { |
| 634 | 634 | return error.SkipZigTest; |
| 635 | 635 | } |
| 636 | 636 | |
| 637 | const initial_value = "\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00".*; | |
| 638 | const expected_output = "\x68\x4c\xf5\x9b\xa8\x33\x09\x55\x28\x00\xef\x56\x6f\x2f\x4d\x3c\x1c\x38\x87\xc4\x93\x60\xe3\x87\x5f\x2e\xb9\x4d\x99\x53\x2c\x51".*; | |
| 637 | const initial_value = "\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; | |
| 638 | const expected_output = "\x68\x4c\xf5\x9b\xa8\x33\x09\x55\x28\x00\xef\x56\x6f\x2f\x4d\x3c\x1c\x38\x87\xc4\x93\x60\xe3\x87\x5f\x2e\xb9\x4d\x99\x53\x2c\x51"; | |
| 639 | 639 | |
| 640 | var k: [32]u8 = initial_value; | |
| 641 | var u: [32]u8 = initial_value; | |
| 640 | var k: [32]u8 = initial_value.*; | |
| 641 | var u: [32]u8 = initial_value.*; | |
| 642 | 642 | |
| 643 | 643 | var i: usize = 0; |
| 644 | 644 | while (i < 1000) : (i += 1) { |
| 645 | 645 | var output: [32]u8 = undefined; |
| 646 | std.testing.expect(X25519.create(output[0..], k, u)); | |
| 646 | std.testing.expect(X25519.create(output[0..], &k, &u)); | |
| 647 | 647 | |
| 648 | 648 | std.mem.copy(u8, u[0..], k[0..]); |
| 649 | 649 | std.mem.copy(u8, k[0..], output[0..]); |
| ... | ... | @@ -657,16 +657,16 @@ test "x25519 rfc7748 1,000,000 iterations" { |
| 657 | 657 | return error.SkipZigTest; |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | const initial_value = "\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00".*; | |
| 661 | const expected_output = "\x7c\x39\x11\xe0\xab\x25\x86\xfd\x86\x44\x97\x29\x7e\x57\x5e\x6f\x3b\xc6\x01\xc0\x88\x3c\x30\xdf\x5f\x4d\xd2\xd2\x4f\x66\x54\x24".*; | |
| 660 | const initial_value = "\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; | |
| 661 | const expected_output = "\x7c\x39\x11\xe0\xab\x25\x86\xfd\x86\x44\x97\x29\x7e\x57\x5e\x6f\x3b\xc6\x01\xc0\x88\x3c\x30\xdf\x5f\x4d\xd2\xd2\x4f\x66\x54\x24"; | |
| 662 | 662 | |
| 663 | var k: [32]u8 = initial_value; | |
| 664 | var u: [32]u8 = initial_value; | |
| 663 | var k: [32]u8 = initial_value.*; | |
| 664 | var u: [32]u8 = initial_value.*; | |
| 665 | 665 | |
| 666 | 666 | var i: usize = 0; |
| 667 | 667 | while (i < 1000000) : (i += 1) { |
| 668 | 668 | var output: [32]u8 = undefined; |
| 669 | std.testing.expect(X25519.create(output[0..], k, u)); | |
| 669 | std.testing.expect(X25519.create(output[0..], &k, &u)); | |
| 670 | 670 | |
| 671 | 671 | std.mem.copy(u8, u[0..], k[0..]); |
| 672 | 672 | std.mem.copy(u8, k[0..], output[0..]); |
lib/std/debug.zig+1-1| ... | ... | @@ -1916,7 +1916,7 @@ const LineNumberProgram = struct { |
| 1916 | 1916 | return error.InvalidDebugInfo; |
| 1917 | 1917 | } else |
| 1918 | 1918 | self.include_dirs[file_entry.dir_index]; |
| 1919 | const file_name = try fs.path.join(self.file_entries.allocator, [_][]const u8{ dir_name, file_entry.file_name }); | |
| 1919 | const file_name = try fs.path.join(self.file_entries.allocator, &[_][]const u8{ dir_name, file_entry.file_name }); | |
| 1920 | 1920 | errdefer self.file_entries.allocator.free(file_name); |
| 1921 | 1921 | return LineInfo{ |
| 1922 | 1922 | .line = if (self.prev_line >= 0) @intCast(u64, self.prev_line) else 0, |
lib/std/elf.zig+1-1| ... | ... | @@ -381,7 +381,7 @@ pub const Elf = struct { |
| 381 | 381 | |
| 382 | 382 | var magic: [4]u8 = undefined; |
| 383 | 383 | try in.readNoEof(magic[0..]); |
| 384 | if (!mem.eql(u8, magic, "\x7fELF")) return error.InvalidFormat; | |
| 384 | if (!mem.eql(u8, &magic, "\x7fELF")) return error.InvalidFormat; | |
| 385 | 385 | |
| 386 | 386 | elf.is_64 = switch (try in.readByte()) { |
| 387 | 387 | 1 => false, |
lib/std/event/loop.zig+2-2| ... | ... | @@ -237,7 +237,7 @@ pub const Loop = struct { |
| 237 | 237 | var extra_thread_index: usize = 0; |
| 238 | 238 | errdefer { |
| 239 | 239 | // writing 8 bytes to an eventfd cannot fail |
| 240 | os.write(self.os_data.final_eventfd, wakeup_bytes) catch unreachable; | |
| 240 | os.write(self.os_data.final_eventfd, &wakeup_bytes) catch unreachable; | |
| 241 | 241 | while (extra_thread_index != 0) { |
| 242 | 242 | extra_thread_index -= 1; |
| 243 | 243 | self.extra_threads[extra_thread_index].wait(); |
| ... | ... | @@ -684,7 +684,7 @@ pub const Loop = struct { |
| 684 | 684 | .linux => { |
| 685 | 685 | self.posixFsRequest(&self.os_data.fs_end_request); |
| 686 | 686 | // writing 8 bytes to an eventfd cannot fail |
| 687 | noasync os.write(self.os_data.final_eventfd, wakeup_bytes) catch unreachable; | |
| 687 | noasync os.write(self.os_data.final_eventfd, &wakeup_bytes) catch unreachable; | |
| 688 | 688 | return; |
| 689 | 689 | }, |
| 690 | 690 | .macosx, .freebsd, .netbsd, .dragonfly => { |
lib/std/fifo.zig+5-5| ... | ... | @@ -70,7 +70,7 @@ pub fn LinearFifo( |
| 70 | 70 | pub fn init(allocator: *Allocator) Self { |
| 71 | 71 | return .{ |
| 72 | 72 | .allocator = allocator, |
| 73 | .buf = [_]T{}, | |
| 73 | .buf = &[_]T{}, | |
| 74 | 74 | .head = 0, |
| 75 | 75 | .count = 0, |
| 76 | 76 | }; |
| ... | ... | @@ -143,7 +143,7 @@ pub fn LinearFifo( |
| 143 | 143 | |
| 144 | 144 | /// Returns a writable slice from the 'read' end of the fifo |
| 145 | 145 | fn readableSliceMut(self: SliceSelfArg, offset: usize) []T { |
| 146 | if (offset > self.count) return [_]T{}; | |
| 146 | if (offset > self.count) return &[_]T{}; | |
| 147 | 147 | |
| 148 | 148 | var start = self.head + offset; |
| 149 | 149 | if (start >= self.buf.len) { |
| ... | ... | @@ -223,7 +223,7 @@ pub fn LinearFifo( |
| 223 | 223 | /// Returns the first section of writable buffer |
| 224 | 224 | /// Note that this may be of length 0 |
| 225 | 225 | pub fn writableSlice(self: SliceSelfArg, offset: usize) []T { |
| 226 | if (offset > self.buf.len) return [_]T{}; | |
| 226 | if (offset > self.buf.len) return &[_]T{}; | |
| 227 | 227 | |
| 228 | 228 | const tail = self.head + offset + self.count; |
| 229 | 229 | if (tail < self.buf.len) { |
| ... | ... | @@ -357,7 +357,7 @@ test "LinearFifo(u8, .Dynamic)" { |
| 357 | 357 | { |
| 358 | 358 | var i: usize = 0; |
| 359 | 359 | while (i < 5) : (i += 1) { |
| 360 | try fifo.write([_]u8{try fifo.peekItem(i)}); | |
| 360 | try fifo.write(&[_]u8{try fifo.peekItem(i)}); | |
| 361 | 361 | } |
| 362 | 362 | testing.expectEqual(@as(usize, 10), fifo.readableLength()); |
| 363 | 363 | testing.expectEqualSlices(u8, "HELLOHELLO", fifo.readableSlice(0)); |
| ... | ... | @@ -426,7 +426,7 @@ test "LinearFifo" { |
| 426 | 426 | }; |
| 427 | 427 | defer fifo.deinit(); |
| 428 | 428 | |
| 429 | try fifo.write([_]T{ 0, 1, 1, 0, 1 }); | |
| 429 | try fifo.write(&[_]T{ 0, 1, 1, 0, 1 }); | |
| 430 | 430 | testing.expectEqual(@as(usize, 5), fifo.readableLength()); |
| 431 | 431 | |
| 432 | 432 | { |
lib/std/fmt.zig+15-10| ... | ... | @@ -451,13 +451,18 @@ pub fn formatType( |
| 451 | 451 | }, |
| 452 | 452 | }, |
| 453 | 453 | .Array => |info| { |
| 454 | if (info.child == u8) { | |
| 455 | return formatText(value, fmt, options, context, Errors, output); | |
| 456 | } | |
| 457 | if (value.len == 0) { | |
| 458 | return format(context, Errors, output, "[0]{}", @typeName(T.Child)); | |
| 459 | } | |
| 460 | return format(context, Errors, output, "{}@{x}", @typeName(T.Child), @ptrToInt(&value)); | |
| 454 | const Slice = @Type(builtin.TypeInfo{ | |
| 455 | .Pointer = .{ | |
| 456 | .size = .Slice, | |
| 457 | .is_const = true, | |
| 458 | .is_volatile = false, | |
| 459 | .is_allowzero = false, | |
| 460 | .alignment = @alignOf(info.child), | |
| 461 | .child = info.child, | |
| 462 | .sentinel = null, | |
| 463 | }, | |
| 464 | }); | |
| 465 | return formatType(@as(Slice, &value), fmt, options, context, Errors, output, max_depth); | |
| 461 | 466 | }, |
| 462 | 467 | .Fn => { |
| 463 | 468 | return format(context, Errors, output, "{}@{x}", @typeName(T), @ptrToInt(value)); |
| ... | ... | @@ -872,8 +877,8 @@ pub fn formatBytes( |
| 872 | 877 | } |
| 873 | 878 | |
| 874 | 879 | const buf = switch (radix) { |
| 875 | 1000 => [_]u8{ suffix, 'B' }, | |
| 876 | 1024 => [_]u8{ suffix, 'i', 'B' }, | |
| 880 | 1000 => &[_]u8{ suffix, 'B' }, | |
| 881 | 1024 => &[_]u8{ suffix, 'i', 'B' }, | |
| 877 | 882 | else => unreachable, |
| 878 | 883 | }; |
| 879 | 884 | return output(context, buf); |
| ... | ... | @@ -969,7 +974,7 @@ fn formatIntUnsigned( |
| 969 | 974 | if (leftover_padding == 0) break; |
| 970 | 975 | } |
| 971 | 976 | mem.set(u8, buf[0..index], options.fill); |
| 972 | return output(context, buf); | |
| 977 | return output(context, &buf); | |
| 973 | 978 | } else { |
| 974 | 979 | const padded_buf = buf[index - padding ..]; |
| 975 | 980 | mem.set(u8, padded_buf[0..padding], options.fill); |
lib/std/fs.zig+3-3| ... | ... | @@ -60,7 +60,7 @@ pub fn atomicSymLink(allocator: *Allocator, existing_path: []const u8, new_path: |
| 60 | 60 | tmp_path[dirname.len] = path.sep; |
| 61 | 61 | while (true) { |
| 62 | 62 | try crypto.randomBytes(rand_buf[0..]); |
| 63 | b64_fs_encoder.encode(tmp_path[dirname.len + 1 ..], rand_buf); | |
| 63 | b64_fs_encoder.encode(tmp_path[dirname.len + 1 ..], &rand_buf); | |
| 64 | 64 | |
| 65 | 65 | if (symLink(existing_path, tmp_path)) { |
| 66 | 66 | return rename(tmp_path, new_path); |
| ... | ... | @@ -226,7 +226,7 @@ pub const AtomicFile = struct { |
| 226 | 226 | |
| 227 | 227 | while (true) { |
| 228 | 228 | try crypto.randomBytes(rand_buf[0..]); |
| 229 | b64_fs_encoder.encode(tmp_path_buf[dirname_component_len..tmp_path_len], rand_buf); | |
| 229 | b64_fs_encoder.encode(tmp_path_buf[dirname_component_len..tmp_path_len], &rand_buf); | |
| 230 | 230 | |
| 231 | 231 | const file = File.openWriteNoClobberC(@ptrCast([*:0]u8, &tmp_path_buf), mode) catch |err| switch (err) { |
| 232 | 232 | error.PathAlreadyExists => continue, |
| ... | ... | @@ -290,7 +290,7 @@ pub fn makeDirW(dir_path: [*:0]const u16) !void { |
| 290 | 290 | /// have been modified regardless. |
| 291 | 291 | /// TODO determine if we can remove the allocator requirement from this function |
| 292 | 292 | pub fn makePath(allocator: *Allocator, full_path: []const u8) !void { |
| 293 | const resolved_path = try path.resolve(allocator, [_][]const u8{full_path}); | |
| 293 | const resolved_path = try path.resolve(allocator, &[_][]const u8{full_path}); | |
| 294 | 294 | defer allocator.free(resolved_path); |
| 295 | 295 | |
| 296 | 296 | var end_index: usize = resolved_path.len; |
lib/std/fs/get_app_data_dir.zig+3-3| ... | ... | @@ -31,7 +31,7 @@ pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataD |
| 31 | 31 | error.OutOfMemory => return error.OutOfMemory, |
| 32 | 32 | }; |
| 33 | 33 | defer allocator.free(global_dir); |
| 34 | return fs.path.join(allocator, [_][]const u8{ global_dir, appname }); | |
| 34 | return fs.path.join(allocator, &[_][]const u8{ global_dir, appname }); | |
| 35 | 35 | }, |
| 36 | 36 | os.windows.E_OUTOFMEMORY => return error.OutOfMemory, |
| 37 | 37 | else => return error.AppDataDirUnavailable, |
| ... | ... | @@ -42,14 +42,14 @@ pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataD |
| 42 | 42 | // TODO look in /etc/passwd |
| 43 | 43 | return error.AppDataDirUnavailable; |
| 44 | 44 | }; |
| 45 | return fs.path.join(allocator, [_][]const u8{ home_dir, "Library", "Application Support", appname }); | |
| 45 | return fs.path.join(allocator, &[_][]const u8{ home_dir, "Library", "Application Support", appname }); | |
| 46 | 46 | }, |
| 47 | 47 | .linux, .freebsd, .netbsd, .dragonfly => { |
| 48 | 48 | const home_dir = os.getenv("HOME") orelse { |
| 49 | 49 | // TODO look in /etc/passwd |
| 50 | 50 | return error.AppDataDirUnavailable; |
| 51 | 51 | }; |
| 52 | return fs.path.join(allocator, [_][]const u8{ home_dir, ".local", "share", appname }); | |
| 52 | return fs.path.join(allocator, &[_][]const u8{ home_dir, ".local", "share", appname }); | |
| 53 | 53 | }, |
| 54 | 54 | else => @compileError("Unsupported OS"), |
| 55 | 55 | } |
lib/std/fs/path.zig+62-60| ... | ... | @@ -15,7 +15,9 @@ pub const sep_windows = '\\'; |
| 15 | 15 | pub const sep_posix = '/'; |
| 16 | 16 | pub const sep = if (builtin.os == .windows) sep_windows else sep_posix; |
| 17 | 17 | |
| 18 | pub const sep_str = [1]u8{sep}; | |
| 18 | pub const sep_str_windows = "\\"; | |
| 19 | pub const sep_str_posix = "/"; | |
| 20 | pub const sep_str = if (builtin.os == .windows) sep_str_windows else sep_str_posix; | |
| 19 | 21 | |
| 20 | 22 | pub const delimiter_windows = ';'; |
| 21 | 23 | pub const delimiter_posix = ':'; |
| ... | ... | @@ -101,31 +103,31 @@ fn testJoinPosix(paths: []const []const u8, expected: []const u8) void { |
| 101 | 103 | } |
| 102 | 104 | |
| 103 | 105 | test "join" { |
| 104 | testJoinWindows([_][]const u8{ "c:\\a\\b", "c" }, "c:\\a\\b\\c"); | |
| 105 | testJoinWindows([_][]const u8{ "c:\\a\\b", "c" }, "c:\\a\\b\\c"); | |
| 106 | testJoinWindows([_][]const u8{ "c:\\a\\b\\", "c" }, "c:\\a\\b\\c"); | |
| 106 | testJoinWindows(&[_][]const u8{ "c:\\a\\b", "c" }, "c:\\a\\b\\c"); | |
| 107 | testJoinWindows(&[_][]const u8{ "c:\\a\\b", "c" }, "c:\\a\\b\\c"); | |
| 108 | testJoinWindows(&[_][]const u8{ "c:\\a\\b\\", "c" }, "c:\\a\\b\\c"); | |
| 107 | 109 | |
| 108 | testJoinWindows([_][]const u8{ "c:\\", "a", "b\\", "c" }, "c:\\a\\b\\c"); | |
| 109 | testJoinWindows([_][]const u8{ "c:\\a\\", "b\\", "c" }, "c:\\a\\b\\c"); | |
| 110 | testJoinWindows(&[_][]const u8{ "c:\\", "a", "b\\", "c" }, "c:\\a\\b\\c"); | |
| 111 | testJoinWindows(&[_][]const u8{ "c:\\a\\", "b\\", "c" }, "c:\\a\\b\\c"); | |
| 110 | 112 | |
| 111 | 113 | testJoinWindows( |
| 112 | [_][]const u8{ "c:\\home\\andy\\dev\\zig\\build\\lib\\zig\\std", "io.zig" }, | |
| 114 | &[_][]const u8{ "c:\\home\\andy\\dev\\zig\\build\\lib\\zig\\std", "io.zig" }, | |
| 113 | 115 | "c:\\home\\andy\\dev\\zig\\build\\lib\\zig\\std\\io.zig", |
| 114 | 116 | ); |
| 115 | 117 | |
| 116 | testJoinPosix([_][]const u8{ "/a/b", "c" }, "/a/b/c"); | |
| 117 | testJoinPosix([_][]const u8{ "/a/b/", "c" }, "/a/b/c"); | |
| 118 | testJoinPosix(&[_][]const u8{ "/a/b", "c" }, "/a/b/c"); | |
| 119 | testJoinPosix(&[_][]const u8{ "/a/b/", "c" }, "/a/b/c"); | |
| 118 | 120 | |
| 119 | testJoinPosix([_][]const u8{ "/", "a", "b/", "c" }, "/a/b/c"); | |
| 120 | testJoinPosix([_][]const u8{ "/a/", "b/", "c" }, "/a/b/c"); | |
| 121 | testJoinPosix(&[_][]const u8{ "/", "a", "b/", "c" }, "/a/b/c"); | |
| 122 | testJoinPosix(&[_][]const u8{ "/a/", "b/", "c" }, "/a/b/c"); | |
| 121 | 123 | |
| 122 | 124 | testJoinPosix( |
| 123 | [_][]const u8{ "/home/andy/dev/zig/build/lib/zig/std", "io.zig" }, | |
| 125 | &[_][]const u8{ "/home/andy/dev/zig/build/lib/zig/std", "io.zig" }, | |
| 124 | 126 | "/home/andy/dev/zig/build/lib/zig/std/io.zig", |
| 125 | 127 | ); |
| 126 | 128 | |
| 127 | testJoinPosix([_][]const u8{ "a", "/c" }, "a/c"); | |
| 128 | testJoinPosix([_][]const u8{ "a/", "/c" }, "a/c"); | |
| 129 | testJoinPosix(&[_][]const u8{ "a", "/c" }, "a/c"); | |
| 130 | testJoinPosix(&[_][]const u8{ "a/", "/c" }, "a/c"); | |
| 129 | 131 | } |
| 130 | 132 | |
| 131 | 133 | pub fn isAbsolute(path: []const u8) bool { |
| ... | ... | @@ -246,7 +248,7 @@ pub fn windowsParsePath(path: []const u8) WindowsPath { |
| 246 | 248 | } |
| 247 | 249 | const relative_path = WindowsPath{ |
| 248 | 250 | .kind = WindowsPath.Kind.None, |
| 249 | .disk_designator = [_]u8{}, | |
| 251 | .disk_designator = &[_]u8{}, | |
| 250 | 252 | .is_abs = false, |
| 251 | 253 | }; |
| 252 | 254 | if (path.len < "//a/b".len) { |
| ... | ... | @@ -255,12 +257,12 @@ pub fn windowsParsePath(path: []const u8) WindowsPath { |
| 255 | 257 | |
| 256 | 258 | inline for ("/\\") |this_sep| { |
| 257 | 259 | const two_sep = [_]u8{ this_sep, this_sep }; |
| 258 | if (mem.startsWith(u8, path, two_sep)) { | |
| 260 | if (mem.startsWith(u8, path, &two_sep)) { | |
| 259 | 261 | if (path[2] == this_sep) { |
| 260 | 262 | return relative_path; |
| 261 | 263 | } |
| 262 | 264 | |
| 263 | var it = mem.tokenize(path, [_]u8{this_sep}); | |
| 265 | var it = mem.tokenize(path, &[_]u8{this_sep}); | |
| 264 | 266 | _ = (it.next() orelse return relative_path); |
| 265 | 267 | _ = (it.next() orelse return relative_path); |
| 266 | 268 | return WindowsPath{ |
| ... | ... | @@ -322,8 +324,8 @@ fn networkShareServersEql(ns1: []const u8, ns2: []const u8) bool { |
| 322 | 324 | const sep1 = ns1[0]; |
| 323 | 325 | const sep2 = ns2[0]; |
| 324 | 326 | |
| 325 | var it1 = mem.tokenize(ns1, [_]u8{sep1}); | |
| 326 | var it2 = mem.tokenize(ns2, [_]u8{sep2}); | |
| 327 | var it1 = mem.tokenize(ns1, &[_]u8{sep1}); | |
| 328 | var it2 = mem.tokenize(ns2, &[_]u8{sep2}); | |
| 327 | 329 | |
| 328 | 330 | // TODO ASCII is wrong, we actually need full unicode support to compare paths. |
| 329 | 331 | return asciiEqlIgnoreCase(it1.next().?, it2.next().?); |
| ... | ... | @@ -343,8 +345,8 @@ fn compareDiskDesignators(kind: WindowsPath.Kind, p1: []const u8, p2: []const u8 |
| 343 | 345 | const sep1 = p1[0]; |
| 344 | 346 | const sep2 = p2[0]; |
| 345 | 347 | |
| 346 | var it1 = mem.tokenize(p1, [_]u8{sep1}); | |
| 347 | var it2 = mem.tokenize(p2, [_]u8{sep2}); | |
| 348 | var it1 = mem.tokenize(p1, &[_]u8{sep1}); | |
| 349 | var it2 = mem.tokenize(p2, &[_]u8{sep2}); | |
| 348 | 350 | |
| 349 | 351 | // TODO ASCII is wrong, we actually need full unicode support to compare paths. |
| 350 | 352 | return asciiEqlIgnoreCase(it1.next().?, it2.next().?) and asciiEqlIgnoreCase(it1.next().?, it2.next().?); |
| ... | ... | @@ -637,10 +639,10 @@ test "resolve" { |
| 637 | 639 | if (windowsParsePath(cwd).kind == WindowsPath.Kind.Drive) { |
| 638 | 640 | cwd[0] = asciiUpper(cwd[0]); |
| 639 | 641 | } |
| 640 | testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{"."}), cwd)); | |
| 642 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{"."}), cwd)); | |
| 641 | 643 | } else { |
| 642 | testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{ "a/b/c/", "../../.." }), cwd)); | |
| 643 | testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{"."}), cwd)); | |
| 644 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "a/b/c/", "../../.." }), cwd)); | |
| 645 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{"."}), cwd)); | |
| 644 | 646 | } |
| 645 | 647 | } |
| 646 | 648 | |
| ... | ... | @@ -653,8 +655,8 @@ test "resolveWindows" { |
| 653 | 655 | const cwd = try process.getCwdAlloc(debug.global_allocator); |
| 654 | 656 | const parsed_cwd = windowsParsePath(cwd); |
| 655 | 657 | { |
| 656 | const result = testResolveWindows([_][]const u8{ "/usr/local", "lib\\zig\\std\\array_list.zig" }); | |
| 657 | const expected = try join(debug.global_allocator, [_][]const u8{ | |
| 658 | const result = testResolveWindows(&[_][]const u8{ "/usr/local", "lib\\zig\\std\\array_list.zig" }); | |
| 659 | const expected = try join(debug.global_allocator, &[_][]const u8{ | |
| 658 | 660 | parsed_cwd.disk_designator, |
| 659 | 661 | "usr\\local\\lib\\zig\\std\\array_list.zig", |
| 660 | 662 | }); |
| ... | ... | @@ -664,8 +666,8 @@ test "resolveWindows" { |
| 664 | 666 | testing.expect(mem.eql(u8, result, expected)); |
| 665 | 667 | } |
| 666 | 668 | { |
| 667 | const result = testResolveWindows([_][]const u8{ "usr/local", "lib\\zig" }); | |
| 668 | const expected = try join(debug.global_allocator, [_][]const u8{ | |
| 669 | const result = testResolveWindows(&[_][]const u8{ "usr/local", "lib\\zig" }); | |
| 670 | const expected = try join(debug.global_allocator, &[_][]const u8{ | |
| 669 | 671 | cwd, |
| 670 | 672 | "usr\\local\\lib\\zig", |
| 671 | 673 | }); |
| ... | ... | @@ -676,32 +678,32 @@ test "resolveWindows" { |
| 676 | 678 | } |
| 677 | 679 | } |
| 678 | 680 | |
| 679 | testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:\\a\\b\\c", "/hi", "ok" }), "C:\\hi\\ok")); | |
| 680 | testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:/blah\\blah", "d:/games", "c:../a" }), "C:\\blah\\a")); | |
| 681 | testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:/blah\\blah", "d:/games", "C:../a" }), "C:\\blah\\a")); | |
| 682 | testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:/ignore", "d:\\a/b\\c/d", "\\e.exe" }), "D:\\e.exe")); | |
| 683 | testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:/ignore", "c:/some/file" }), "C:\\some\\file")); | |
| 684 | testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "d:/ignore", "d:some/dir//" }), "D:\\ignore\\some\\dir")); | |
| 685 | testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "//server/share", "..", "relative\\" }), "\\\\server\\share\\relative")); | |
| 686 | testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:/", "//" }), "C:\\")); | |
| 687 | testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:/", "//dir" }), "C:\\dir")); | |
| 688 | testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:/", "//server/share" }), "\\\\server\\share\\")); | |
| 689 | testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:/", "//server//share" }), "\\\\server\\share\\")); | |
| 690 | testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:/", "///some//dir" }), "C:\\some\\dir")); | |
| 691 | testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "C:\\foo\\tmp.3\\", "..\\tmp.3\\cycles\\root.js" }), "C:\\foo\\tmp.3\\cycles\\root.js")); | |
| 681 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:\\a\\b\\c", "/hi", "ok" }), "C:\\hi\\ok")); | |
| 682 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/blah\\blah", "d:/games", "c:../a" }), "C:\\blah\\a")); | |
| 683 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/blah\\blah", "d:/games", "C:../a" }), "C:\\blah\\a")); | |
| 684 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/ignore", "d:\\a/b\\c/d", "\\e.exe" }), "D:\\e.exe")); | |
| 685 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/ignore", "c:/some/file" }), "C:\\some\\file")); | |
| 686 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "d:/ignore", "d:some/dir//" }), "D:\\ignore\\some\\dir")); | |
| 687 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "//server/share", "..", "relative\\" }), "\\\\server\\share\\relative")); | |
| 688 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/", "//" }), "C:\\")); | |
| 689 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/", "//dir" }), "C:\\dir")); | |
| 690 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/", "//server/share" }), "\\\\server\\share\\")); | |
| 691 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/", "//server//share" }), "\\\\server\\share\\")); | |
| 692 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/", "///some//dir" }), "C:\\some\\dir")); | |
| 693 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "C:\\foo\\tmp.3\\", "..\\tmp.3\\cycles\\root.js" }), "C:\\foo\\tmp.3\\cycles\\root.js")); | |
| 692 | 694 | } |
| 693 | 695 | |
| 694 | 696 | test "resolvePosix" { |
| 695 | testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{ "/a/b", "c" }), "/a/b/c")); | |
| 696 | testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{ "/a/b", "c", "//d", "e///" }), "/d/e")); | |
| 697 | testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{ "/a/b/c", "..", "../" }), "/a")); | |
| 698 | testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{ "/", "..", ".." }), "/")); | |
| 699 | testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{"/a/b/c/"}), "/a/b/c")); | |
| 700 | ||
| 701 | testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{ "/var/lib", "../", "file/" }), "/var/file")); | |
| 702 | testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{ "/var/lib", "/../", "file/" }), "/file")); | |
| 703 | testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{ "/some/dir", ".", "/absolute/" }), "/absolute")); | |
| 704 | testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{ "/foo/tmp.3/", "../tmp.3/cycles/root.js" }), "/foo/tmp.3/cycles/root.js")); | |
| 697 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/a/b", "c" }), "/a/b/c")); | |
| 698 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/a/b", "c", "//d", "e///" }), "/d/e")); | |
| 699 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/a/b/c", "..", "../" }), "/a")); | |
| 700 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/", "..", ".." }), "/")); | |
| 701 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{"/a/b/c/"}), "/a/b/c")); | |
| 702 | ||
| 703 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/var/lib", "../", "file/" }), "/var/file")); | |
| 704 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/var/lib", "/../", "file/" }), "/file")); | |
| 705 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/some/dir", ".", "/absolute/" }), "/absolute")); | |
| 706 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/foo/tmp.3/", "../tmp.3/cycles/root.js" }), "/foo/tmp.3/cycles/root.js")); | |
| 705 | 707 | } |
| 706 | 708 | |
| 707 | 709 | fn testResolveWindows(paths: []const []const u8) []u8 { |
| ... | ... | @@ -856,12 +858,12 @@ pub fn basename(path: []const u8) []const u8 { |
| 856 | 858 | |
| 857 | 859 | pub fn basenamePosix(path: []const u8) []const u8 { |
| 858 | 860 | if (path.len == 0) |
| 859 | return [_]u8{}; | |
| 861 | return &[_]u8{}; | |
| 860 | 862 | |
| 861 | 863 | var end_index: usize = path.len - 1; |
| 862 | 864 | while (path[end_index] == '/') { |
| 863 | 865 | if (end_index == 0) |
| 864 | return [_]u8{}; | |
| 866 | return &[_]u8{}; | |
| 865 | 867 | end_index -= 1; |
| 866 | 868 | } |
| 867 | 869 | var start_index: usize = end_index; |
| ... | ... | @@ -877,19 +879,19 @@ pub fn basenamePosix(path: []const u8) []const u8 { |
| 877 | 879 | |
| 878 | 880 | pub fn basenameWindows(path: []const u8) []const u8 { |
| 879 | 881 | if (path.len == 0) |
| 880 | return [_]u8{}; | |
| 882 | return &[_]u8{}; | |
| 881 | 883 | |
| 882 | 884 | var end_index: usize = path.len - 1; |
| 883 | 885 | while (true) { |
| 884 | 886 | const byte = path[end_index]; |
| 885 | 887 | if (byte == '/' or byte == '\\') { |
| 886 | 888 | if (end_index == 0) |
| 887 | return [_]u8{}; | |
| 889 | return &[_]u8{}; | |
| 888 | 890 | end_index -= 1; |
| 889 | 891 | continue; |
| 890 | 892 | } |
| 891 | 893 | if (byte == ':' and end_index == 1) { |
| 892 | return [_]u8{}; | |
| 894 | return &[_]u8{}; | |
| 893 | 895 | } |
| 894 | 896 | break; |
| 895 | 897 | } |
| ... | ... | @@ -971,11 +973,11 @@ pub fn relative(allocator: *Allocator, from: []const u8, to: []const u8) ![]u8 { |
| 971 | 973 | } |
| 972 | 974 | |
| 973 | 975 | pub fn relativeWindows(allocator: *Allocator, from: []const u8, to: []const u8) ![]u8 { |
| 974 | const resolved_from = try resolveWindows(allocator, [_][]const u8{from}); | |
| 976 | const resolved_from = try resolveWindows(allocator, &[_][]const u8{from}); | |
| 975 | 977 | defer allocator.free(resolved_from); |
| 976 | 978 | |
| 977 | 979 | var clean_up_resolved_to = true; |
| 978 | const resolved_to = try resolveWindows(allocator, [_][]const u8{to}); | |
| 980 | const resolved_to = try resolveWindows(allocator, &[_][]const u8{to}); | |
| 979 | 981 | defer if (clean_up_resolved_to) allocator.free(resolved_to); |
| 980 | 982 | |
| 981 | 983 | const parsed_from = windowsParsePath(resolved_from); |
| ... | ... | @@ -1044,10 +1046,10 @@ pub fn relativeWindows(allocator: *Allocator, from: []const u8, to: []const u8) |
| 1044 | 1046 | } |
| 1045 | 1047 | |
| 1046 | 1048 | pub fn relativePosix(allocator: *Allocator, from: []const u8, to: []const u8) ![]u8 { |
| 1047 | const resolved_from = try resolvePosix(allocator, [_][]const u8{from}); | |
| 1049 | const resolved_from = try resolvePosix(allocator, &[_][]const u8{from}); | |
| 1048 | 1050 | defer allocator.free(resolved_from); |
| 1049 | 1051 | |
| 1050 | const resolved_to = try resolvePosix(allocator, [_][]const u8{to}); | |
| 1052 | const resolved_to = try resolvePosix(allocator, &[_][]const u8{to}); | |
| 1051 | 1053 | defer allocator.free(resolved_to); |
| 1052 | 1054 | |
| 1053 | 1055 | var from_it = mem.tokenize(resolved_from, "/"); |
lib/std/hash/cityhash.zig+1-1| ... | ... | @@ -367,7 +367,7 @@ fn SMHasherTest(comptime hash_fn: var, comptime hashbits: u32) u32 { |
| 367 | 367 | @memcpy(@ptrCast([*]u8, &hashes[i * hashbytes]), @ptrCast([*]u8, &h), hashbytes); |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | return @truncate(u32, hash_fn(hashes, 0)); | |
| 370 | return @truncate(u32, hash_fn(&hashes, 0)); | |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | fn CityHash32hashIgnoreSeed(str: []const u8, seed: u32) u32 { |
lib/std/hash/murmur.zig+1-1| ... | ... | @@ -299,7 +299,7 @@ fn SMHasherTest(comptime hash_fn: var, comptime hashbits: u32) u32 { |
| 299 | 299 | @memcpy(@ptrCast([*]u8, &hashes[i * hashbytes]), @ptrCast([*]u8, &h), hashbytes); |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | return @truncate(u32, hash_fn(hashes, 0)); | |
| 302 | return @truncate(u32, hash_fn(&hashes, 0)); | |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | test "murmur2_32" { |
lib/std/hash_map.zig+1-1| ... | ... | @@ -94,7 +94,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3 |
| 94 | 94 | |
| 95 | 95 | pub fn init(allocator: *Allocator) Self { |
| 96 | 96 | return Self{ |
| 97 | .entries = [_]Entry{}, | |
| 97 | .entries = &[_]Entry{}, | |
| 98 | 98 | .allocator = allocator, |
| 99 | 99 | .size = 0, |
| 100 | 100 | .max_distance_from_start_index = 0, |
lib/std/http/headers.zig+2-2| ... | ... | @@ -514,8 +514,8 @@ test "Headers.getIndices" { |
| 514 | 514 | try h.append("set-cookie", "y=2", null); |
| 515 | 515 | |
| 516 | 516 | testing.expect(null == h.getIndices("not-present")); |
| 517 | testing.expectEqualSlices(usize, [_]usize{0}, h.getIndices("foo").?.toSliceConst()); | |
| 518 | testing.expectEqualSlices(usize, [_]usize{ 1, 2 }, h.getIndices("set-cookie").?.toSliceConst()); | |
| 517 | testing.expectEqualSlices(usize, &[_]usize{0}, h.getIndices("foo").?.toSliceConst()); | |
| 518 | testing.expectEqualSlices(usize, &[_]usize{ 1, 2 }, h.getIndices("set-cookie").?.toSliceConst()); | |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | test "Headers.get" { |
lib/std/io.zig+1-1| ... | ... | @@ -1107,7 +1107,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co |
| 1107 | 1107 | byte.* = if (t_bit_count < u8_bit_count) v else @truncate(u8, v); |
| 1108 | 1108 | } |
| 1109 | 1109 | |
| 1110 | try self.out_stream.write(buffer); | |
| 1110 | try self.out_stream.write(&buffer); | |
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | 1113 | /// Serializes the passed value into the stream |
lib/std/io/out_stream.zig+5-5| ... | ... | @@ -56,32 +56,32 @@ pub fn OutStream(comptime WriteError: type) type { |
| 56 | 56 | pub fn writeIntNative(self: *Self, comptime T: type, value: T) Error!void { |
| 57 | 57 | var bytes: [(T.bit_count + 7) / 8]u8 = undefined; |
| 58 | 58 | mem.writeIntNative(T, &bytes, value); |
| 59 | return self.writeFn(self, bytes); | |
| 59 | return self.writeFn(self, &bytes); | |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /// Write a foreign-endian integer. |
| 63 | 63 | pub fn writeIntForeign(self: *Self, comptime T: type, value: T) Error!void { |
| 64 | 64 | var bytes: [(T.bit_count + 7) / 8]u8 = undefined; |
| 65 | 65 | mem.writeIntForeign(T, &bytes, value); |
| 66 | return self.writeFn(self, bytes); | |
| 66 | return self.writeFn(self, &bytes); | |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | pub fn writeIntLittle(self: *Self, comptime T: type, value: T) Error!void { |
| 70 | 70 | var bytes: [(T.bit_count + 7) / 8]u8 = undefined; |
| 71 | 71 | mem.writeIntLittle(T, &bytes, value); |
| 72 | return self.writeFn(self, bytes); | |
| 72 | return self.writeFn(self, &bytes); | |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | pub fn writeIntBig(self: *Self, comptime T: type, value: T) Error!void { |
| 76 | 76 | var bytes: [(T.bit_count + 7) / 8]u8 = undefined; |
| 77 | 77 | mem.writeIntBig(T, &bytes, value); |
| 78 | return self.writeFn(self, bytes); | |
| 78 | return self.writeFn(self, &bytes); | |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | pub fn writeInt(self: *Self, comptime T: type, value: T, endian: builtin.Endian) Error!void { |
| 82 | 82 | var bytes: [(T.bit_count + 7) / 8]u8 = undefined; |
| 83 | 83 | mem.writeInt(T, &bytes, value, endian); |
| 84 | return self.writeFn(self, bytes); | |
| 84 | return self.writeFn(self, &bytes); | |
| 85 | 85 | } |
| 86 | 86 | }; |
| 87 | 87 | } |
lib/std/io/test.zig+4-4| ... | ... | @@ -55,7 +55,7 @@ test "write a file, read it, then delete it" { |
| 55 | 55 | defer allocator.free(contents); |
| 56 | 56 | |
| 57 | 57 | expect(mem.eql(u8, contents[0.."begin".len], "begin")); |
| 58 | expect(mem.eql(u8, contents["begin".len .. contents.len - "end".len], data)); | |
| 58 | expect(mem.eql(u8, contents["begin".len .. contents.len - "end".len], &data)); | |
| 59 | 59 | expect(mem.eql(u8, contents[contents.len - "end".len ..], "end")); |
| 60 | 60 | } |
| 61 | 61 | try fs.deleteFile(tmp_file_name); |
| ... | ... | @@ -77,7 +77,7 @@ test "BufferOutStream" { |
| 77 | 77 | |
| 78 | 78 | test "SliceInStream" { |
| 79 | 79 | const bytes = [_]u8{ 1, 2, 3, 4, 5, 6, 7 }; |
| 80 | var ss = io.SliceInStream.init(bytes); | |
| 80 | var ss = io.SliceInStream.init(&bytes); | |
| 81 | 81 | |
| 82 | 82 | var dest: [4]u8 = undefined; |
| 83 | 83 | |
| ... | ... | @@ -95,7 +95,7 @@ test "SliceInStream" { |
| 95 | 95 | |
| 96 | 96 | test "PeekStream" { |
| 97 | 97 | const bytes = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 98 | var ss = io.SliceInStream.init(bytes); | |
| 98 | var ss = io.SliceInStream.init(&bytes); | |
| 99 | 99 | var ps = io.PeekStream(2, io.SliceInStream.Error).init(&ss.stream); |
| 100 | 100 | |
| 101 | 101 | var dest: [4]u8 = undefined; |
| ... | ... | @@ -614,7 +614,7 @@ test "File seek ops" { |
| 614 | 614 | fs.deleteFile(tmp_file_name) catch {}; |
| 615 | 615 | } |
| 616 | 616 | |
| 617 | try file.write([_]u8{0x55} ** 8192); | |
| 617 | try file.write(&([_]u8{0x55} ** 8192)); | |
| 618 | 618 | |
| 619 | 619 | // Seek to the end |
| 620 | 620 | try file.seekFromEnd(0); |
lib/std/mem.zig+52-76| ... | ... | @@ -624,23 +624,23 @@ test "comptime read/write int" { |
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | test "readIntBig and readIntLittle" { |
| 627 | testing.expect(readIntSliceBig(u0, [_]u8{}) == 0x0); | |
| 628 | testing.expect(readIntSliceLittle(u0, [_]u8{}) == 0x0); | |
| 627 | testing.expect(readIntSliceBig(u0, &[_]u8{}) == 0x0); | |
| 628 | testing.expect(readIntSliceLittle(u0, &[_]u8{}) == 0x0); | |
| 629 | 629 | |
| 630 | testing.expect(readIntSliceBig(u8, [_]u8{0x32}) == 0x32); | |
| 631 | testing.expect(readIntSliceLittle(u8, [_]u8{0x12}) == 0x12); | |
| 630 | testing.expect(readIntSliceBig(u8, &[_]u8{0x32}) == 0x32); | |
| 631 | testing.expect(readIntSliceLittle(u8, &[_]u8{0x12}) == 0x12); | |
| 632 | 632 | |
| 633 | testing.expect(readIntSliceBig(u16, [_]u8{ 0x12, 0x34 }) == 0x1234); | |
| 634 | testing.expect(readIntSliceLittle(u16, [_]u8{ 0x12, 0x34 }) == 0x3412); | |
| 633 | testing.expect(readIntSliceBig(u16, &[_]u8{ 0x12, 0x34 }) == 0x1234); | |
| 634 | testing.expect(readIntSliceLittle(u16, &[_]u8{ 0x12, 0x34 }) == 0x3412); | |
| 635 | 635 | |
| 636 | testing.expect(readIntSliceBig(u72, [_]u8{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x24 }) == 0x123456789abcdef024); | |
| 637 | testing.expect(readIntSliceLittle(u72, [_]u8{ 0xec, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe }) == 0xfedcba9876543210ec); | |
| 636 | testing.expect(readIntSliceBig(u72, &[_]u8{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x24 }) == 0x123456789abcdef024); | |
| 637 | testing.expect(readIntSliceLittle(u72, &[_]u8{ 0xec, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe }) == 0xfedcba9876543210ec); | |
| 638 | 638 | |
| 639 | testing.expect(readIntSliceBig(i8, [_]u8{0xff}) == -1); | |
| 640 | testing.expect(readIntSliceLittle(i8, [_]u8{0xfe}) == -2); | |
| 639 | testing.expect(readIntSliceBig(i8, &[_]u8{0xff}) == -1); | |
| 640 | testing.expect(readIntSliceLittle(i8, &[_]u8{0xfe}) == -2); | |
| 641 | 641 | |
| 642 | testing.expect(readIntSliceBig(i16, [_]u8{ 0xff, 0xfd }) == -3); | |
| 643 | testing.expect(readIntSliceLittle(i16, [_]u8{ 0xfc, 0xff }) == -4); | |
| 642 | testing.expect(readIntSliceBig(i16, &[_]u8{ 0xff, 0xfd }) == -3); | |
| 643 | testing.expect(readIntSliceLittle(i16, &[_]u8{ 0xfc, 0xff }) == -4); | |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | /// Writes an integer to memory, storing it in twos-complement. |
| ... | ... | @@ -749,34 +749,34 @@ test "writeIntBig and writeIntLittle" { |
| 749 | 749 | var buf9: [9]u8 = undefined; |
| 750 | 750 | |
| 751 | 751 | writeIntBig(u0, &buf0, 0x0); |
| 752 | testing.expect(eql(u8, buf0[0..], [_]u8{})); | |
| 752 | testing.expect(eql(u8, buf0[0..], &[_]u8{})); | |
| 753 | 753 | writeIntLittle(u0, &buf0, 0x0); |
| 754 | testing.expect(eql(u8, buf0[0..], [_]u8{})); | |
| 754 | testing.expect(eql(u8, buf0[0..], &[_]u8{})); | |
| 755 | 755 | |
| 756 | 756 | writeIntBig(u8, &buf1, 0x12); |
| 757 | testing.expect(eql(u8, buf1[0..], [_]u8{0x12})); | |
| 757 | testing.expect(eql(u8, buf1[0..], &[_]u8{0x12})); | |
| 758 | 758 | writeIntLittle(u8, &buf1, 0x34); |
| 759 | testing.expect(eql(u8, buf1[0..], [_]u8{0x34})); | |
| 759 | testing.expect(eql(u8, buf1[0..], &[_]u8{0x34})); | |
| 760 | 760 | |
| 761 | 761 | writeIntBig(u16, &buf2, 0x1234); |
| 762 | testing.expect(eql(u8, buf2[0..], [_]u8{ 0x12, 0x34 })); | |
| 762 | testing.expect(eql(u8, buf2[0..], &[_]u8{ 0x12, 0x34 })); | |
| 763 | 763 | writeIntLittle(u16, &buf2, 0x5678); |
| 764 | testing.expect(eql(u8, buf2[0..], [_]u8{ 0x78, 0x56 })); | |
| 764 | testing.expect(eql(u8, buf2[0..], &[_]u8{ 0x78, 0x56 })); | |
| 765 | 765 | |
| 766 | 766 | writeIntBig(u72, &buf9, 0x123456789abcdef024); |
| 767 | testing.expect(eql(u8, buf9[0..], [_]u8{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x24 })); | |
| 767 | testing.expect(eql(u8, buf9[0..], &[_]u8{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x24 })); | |
| 768 | 768 | writeIntLittle(u72, &buf9, 0xfedcba9876543210ec); |
| 769 | testing.expect(eql(u8, buf9[0..], [_]u8{ 0xec, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe })); | |
| 769 | testing.expect(eql(u8, buf9[0..], &[_]u8{ 0xec, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe })); | |
| 770 | 770 | |
| 771 | 771 | writeIntBig(i8, &buf1, -1); |
| 772 | testing.expect(eql(u8, buf1[0..], [_]u8{0xff})); | |
| 772 | testing.expect(eql(u8, buf1[0..], &[_]u8{0xff})); | |
| 773 | 773 | writeIntLittle(i8, &buf1, -2); |
| 774 | testing.expect(eql(u8, buf1[0..], [_]u8{0xfe})); | |
| 774 | testing.expect(eql(u8, buf1[0..], &[_]u8{0xfe})); | |
| 775 | 775 | |
| 776 | 776 | writeIntBig(i16, &buf2, -3); |
| 777 | testing.expect(eql(u8, buf2[0..], [_]u8{ 0xff, 0xfd })); | |
| 777 | testing.expect(eql(u8, buf2[0..], &[_]u8{ 0xff, 0xfd })); | |
| 778 | 778 | writeIntLittle(i16, &buf2, -4); |
| 779 | testing.expect(eql(u8, buf2[0..], [_]u8{ 0xfc, 0xff })); | |
| 779 | testing.expect(eql(u8, buf2[0..], &[_]u8{ 0xfc, 0xff })); | |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | /// Returns an iterator that iterates over the slices of `buffer` that are not |
| ... | ... | @@ -1004,9 +1004,9 @@ pub fn join(allocator: *Allocator, separator: []const u8, slices: []const []cons |
| 1004 | 1004 | test "mem.join" { |
| 1005 | 1005 | var buf: [1024]u8 = undefined; |
| 1006 | 1006 | const a = &std.heap.FixedBufferAllocator.init(&buf).allocator; |
| 1007 | testing.expect(eql(u8, try join(a, ",", [_][]const u8{ "a", "b", "c" }), "a,b,c")); | |
| 1008 | testing.expect(eql(u8, try join(a, ",", [_][]const u8{"a"}), "a")); | |
| 1009 | testing.expect(eql(u8, try join(a, ",", [_][]const u8{ "a", "", "b", "", "c" }), "a,,b,,c")); | |
| 1007 | testing.expect(eql(u8, try join(a, ",", &[_][]const u8{ "a", "b", "c" }), "a,b,c")); | |
| 1008 | testing.expect(eql(u8, try join(a, ",", &[_][]const u8{"a"}), "a")); | |
| 1009 | testing.expect(eql(u8, try join(a, ",", &[_][]const u8{ "a", "", "b", "", "c" }), "a,,b,,c")); | |
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | 1012 | /// Copies each T from slices into a new slice that exactly holds all the elements. |
| ... | ... | @@ -1037,13 +1037,13 @@ pub fn concat(allocator: *Allocator, comptime T: type, slices: []const []const T |
| 1037 | 1037 | test "concat" { |
| 1038 | 1038 | var buf: [1024]u8 = undefined; |
| 1039 | 1039 | const a = &std.heap.FixedBufferAllocator.init(&buf).allocator; |
| 1040 | testing.expect(eql(u8, try concat(a, u8, [_][]const u8{ "abc", "def", "ghi" }), "abcdefghi")); | |
| 1041 | testing.expect(eql(u32, try concat(a, u32, [_][]const u32{ | |
| 1042 | [_]u32{ 0, 1 }, | |
| 1043 | [_]u32{ 2, 3, 4 }, | |
| 1044 | [_]u32{}, | |
| 1045 | [_]u32{5}, | |
| 1046 | }), [_]u32{ 0, 1, 2, 3, 4, 5 })); | |
| 1040 | testing.expect(eql(u8, try concat(a, u8, &[_][]const u8{ "abc", "def", "ghi" }), "abcdefghi")); | |
| 1041 | testing.expect(eql(u32, try concat(a, u32, &[_][]const u32{ | |
| 1042 | &[_]u32{ 0, 1 }, | |
| 1043 | &[_]u32{ 2, 3, 4 }, | |
| 1044 | &[_]u32{}, | |
| 1045 | &[_]u32{5}, | |
| 1046 | }), &[_]u32{ 0, 1, 2, 3, 4, 5 })); | |
| 1047 | 1047 | } |
| 1048 | 1048 | |
| 1049 | 1049 | test "testStringEquality" { |
| ... | ... | @@ -1111,19 +1111,19 @@ fn testWriteIntImpl() void { |
| 1111 | 1111 | var bytes: [8]u8 = undefined; |
| 1112 | 1112 | |
| 1113 | 1113 | writeIntSlice(u0, bytes[0..], 0, builtin.Endian.Big); |
| 1114 | testing.expect(eql(u8, bytes, [_]u8{ | |
| 1114 | testing.expect(eql(u8, &bytes, &[_]u8{ | |
| 1115 | 1115 | 0x00, 0x00, 0x00, 0x00, |
| 1116 | 1116 | 0x00, 0x00, 0x00, 0x00, |
| 1117 | 1117 | })); |
| 1118 | 1118 | |
| 1119 | 1119 | writeIntSlice(u0, bytes[0..], 0, builtin.Endian.Little); |
| 1120 | testing.expect(eql(u8, bytes, [_]u8{ | |
| 1120 | testing.expect(eql(u8, &bytes, &[_]u8{ | |
| 1121 | 1121 | 0x00, 0x00, 0x00, 0x00, |
| 1122 | 1122 | 0x00, 0x00, 0x00, 0x00, |
| 1123 | 1123 | })); |
| 1124 | 1124 | |
| 1125 | 1125 | writeIntSlice(u64, bytes[0..], 0x12345678CAFEBABE, builtin.Endian.Big); |
| 1126 | testing.expect(eql(u8, bytes, [_]u8{ | |
| 1126 | testing.expect(eql(u8, &bytes, &[_]u8{ | |
| 1127 | 1127 | 0x12, |
| 1128 | 1128 | 0x34, |
| 1129 | 1129 | 0x56, |
| ... | ... | @@ -1135,7 +1135,7 @@ fn testWriteIntImpl() void { |
| 1135 | 1135 | })); |
| 1136 | 1136 | |
| 1137 | 1137 | writeIntSlice(u64, bytes[0..], 0xBEBAFECA78563412, builtin.Endian.Little); |
| 1138 | testing.expect(eql(u8, bytes, [_]u8{ | |
| 1138 | testing.expect(eql(u8, &bytes, &[_]u8{ | |
| 1139 | 1139 | 0x12, |
| 1140 | 1140 | 0x34, |
| 1141 | 1141 | 0x56, |
| ... | ... | @@ -1147,7 +1147,7 @@ fn testWriteIntImpl() void { |
| 1147 | 1147 | })); |
| 1148 | 1148 | |
| 1149 | 1149 | writeIntSlice(u32, bytes[0..], 0x12345678, builtin.Endian.Big); |
| 1150 | testing.expect(eql(u8, bytes, [_]u8{ | |
| 1150 | testing.expect(eql(u8, &bytes, &[_]u8{ | |
| 1151 | 1151 | 0x00, |
| 1152 | 1152 | 0x00, |
| 1153 | 1153 | 0x00, |
| ... | ... | @@ -1159,7 +1159,7 @@ fn testWriteIntImpl() void { |
| 1159 | 1159 | })); |
| 1160 | 1160 | |
| 1161 | 1161 | writeIntSlice(u32, bytes[0..], 0x78563412, builtin.Endian.Little); |
| 1162 | testing.expect(eql(u8, bytes, [_]u8{ | |
| 1162 | testing.expect(eql(u8, &bytes, &[_]u8{ | |
| 1163 | 1163 | 0x12, |
| 1164 | 1164 | 0x34, |
| 1165 | 1165 | 0x56, |
| ... | ... | @@ -1171,7 +1171,7 @@ fn testWriteIntImpl() void { |
| 1171 | 1171 | })); |
| 1172 | 1172 | |
| 1173 | 1173 | writeIntSlice(u16, bytes[0..], 0x1234, builtin.Endian.Big); |
| 1174 | testing.expect(eql(u8, bytes, [_]u8{ | |
| 1174 | testing.expect(eql(u8, &bytes, &[_]u8{ | |
| 1175 | 1175 | 0x00, |
| 1176 | 1176 | 0x00, |
| 1177 | 1177 | 0x00, |
| ... | ... | @@ -1183,7 +1183,7 @@ fn testWriteIntImpl() void { |
| 1183 | 1183 | })); |
| 1184 | 1184 | |
| 1185 | 1185 | writeIntSlice(u16, bytes[0..], 0x1234, builtin.Endian.Little); |
| 1186 | testing.expect(eql(u8, bytes, [_]u8{ | |
| 1186 | testing.expect(eql(u8, &bytes, &[_]u8{ | |
| 1187 | 1187 | 0x34, |
| 1188 | 1188 | 0x12, |
| 1189 | 1189 | 0x00, |
| ... | ... | @@ -1235,22 +1235,10 @@ pub fn reverse(comptime T: type, items: []T) void { |
| 1235 | 1235 | } |
| 1236 | 1236 | |
| 1237 | 1237 | test "reverse" { |
| 1238 | var arr = [_]i32{ | |
| 1239 | 5, | |
| 1240 | 3, | |
| 1241 | 1, | |
| 1242 | 2, | |
| 1243 | 4, | |
| 1244 | }; | |
| 1238 | var arr = [_]i32{ 5, 3, 1, 2, 4 }; | |
| 1245 | 1239 | reverse(i32, arr[0..]); |
| 1246 | 1240 | |
| 1247 | testing.expect(eql(i32, arr, [_]i32{ | |
| 1248 | 4, | |
| 1249 | 2, | |
| 1250 | 1, | |
| 1251 | 3, | |
| 1252 | 5, | |
| 1253 | })); | |
| 1241 | testing.expect(eql(i32, &arr, &[_]i32{ 4, 2, 1, 3, 5 })); | |
| 1254 | 1242 | } |
| 1255 | 1243 | |
| 1256 | 1244 | /// In-place rotation of the values in an array ([0 1 2 3] becomes [1 2 3 0] if we rotate by 1) |
| ... | ... | @@ -1262,22 +1250,10 @@ pub fn rotate(comptime T: type, items: []T, amount: usize) void { |
| 1262 | 1250 | } |
| 1263 | 1251 | |
| 1264 | 1252 | test "rotate" { |
| 1265 | var arr = [_]i32{ | |
| 1266 | 5, | |
| 1267 | 3, | |
| 1268 | 1, | |
| 1269 | 2, | |
| 1270 | 4, | |
| 1271 | }; | |
| 1253 | var arr = [_]i32{ 5, 3, 1, 2, 4 }; | |
| 1272 | 1254 | rotate(i32, arr[0..], 2); |
| 1273 | 1255 | |
| 1274 | testing.expect(eql(i32, arr, [_]i32{ | |
| 1275 | 1, | |
| 1276 | 2, | |
| 1277 | 4, | |
| 1278 | 5, | |
| 1279 | 3, | |
| 1280 | })); | |
| 1256 | testing.expect(eql(i32, &arr, &[_]i32{ 1, 2, 4, 5, 3 })); | |
| 1281 | 1257 | } |
| 1282 | 1258 | |
| 1283 | 1259 | /// Converts a little-endian integer to host endianness. |
| ... | ... | @@ -1394,14 +1370,14 @@ pub fn toBytes(value: var) [@sizeOf(@typeOf(value))]u8 { |
| 1394 | 1370 | test "toBytes" { |
| 1395 | 1371 | var my_bytes = toBytes(@as(u32, 0x12345678)); |
| 1396 | 1372 | switch (builtin.endian) { |
| 1397 | builtin.Endian.Big => testing.expect(eql(u8, my_bytes, "\x12\x34\x56\x78")), | |
| 1398 | builtin.Endian.Little => testing.expect(eql(u8, my_bytes, "\x78\x56\x34\x12")), | |
| 1373 | builtin.Endian.Big => testing.expect(eql(u8, &my_bytes, "\x12\x34\x56\x78")), | |
| 1374 | builtin.Endian.Little => testing.expect(eql(u8, &my_bytes, "\x78\x56\x34\x12")), | |
| 1399 | 1375 | } |
| 1400 | 1376 | |
| 1401 | 1377 | my_bytes[0] = '\x99'; |
| 1402 | 1378 | switch (builtin.endian) { |
| 1403 | builtin.Endian.Big => testing.expect(eql(u8, my_bytes, "\x99\x34\x56\x78")), | |
| 1404 | builtin.Endian.Little => testing.expect(eql(u8, my_bytes, "\x99\x56\x34\x12")), | |
| 1379 | builtin.Endian.Big => testing.expect(eql(u8, &my_bytes, "\x99\x34\x56\x78")), | |
| 1380 | builtin.Endian.Little => testing.expect(eql(u8, &my_bytes, "\x99\x56\x34\x12")), | |
| 1405 | 1381 | } |
| 1406 | 1382 | } |
| 1407 | 1383 | |
| ... | ... | @@ -1495,14 +1471,14 @@ pub fn subArrayPtr(ptr: var, comptime start: usize, comptime length: usize) SubA |
| 1495 | 1471 | test "subArrayPtr" { |
| 1496 | 1472 | const a1: [6]u8 = "abcdef".*; |
| 1497 | 1473 | const sub1 = subArrayPtr(&a1, 2, 3); |
| 1498 | testing.expect(eql(u8, sub1.*, "cde")); | |
| 1474 | testing.expect(eql(u8, sub1, "cde")); | |
| 1499 | 1475 | |
| 1500 | 1476 | var a2: [6]u8 = "abcdef".*; |
| 1501 | 1477 | var sub2 = subArrayPtr(&a2, 2, 3); |
| 1502 | 1478 | |
| 1503 | 1479 | testing.expect(eql(u8, sub2, "cde")); |
| 1504 | 1480 | sub2[1] = 'X'; |
| 1505 | testing.expect(eql(u8, a2, "abcXef")); | |
| 1481 | testing.expect(eql(u8, &a2, "abcXef")); | |
| 1506 | 1482 | } |
| 1507 | 1483 | |
| 1508 | 1484 | /// Round an address up to the nearest aligned address |
lib/std/meta/trait.zig+1-1| ... | ... | @@ -46,7 +46,7 @@ test "std.meta.trait.multiTrait" { |
| 46 | 46 | } |
| 47 | 47 | }; |
| 48 | 48 | |
| 49 | const isVector = multiTrait([_]TraitFn{ | |
| 49 | const isVector = multiTrait(&[_]TraitFn{ | |
| 50 | 50 | hasFn("add"), |
| 51 | 51 | hasField("x"), |
| 52 | 52 | hasField("y"), |
lib/std/net.zig+4-4| ... | ... | @@ -291,7 +291,7 @@ pub const Address = extern union { |
| 291 | 291 | }, |
| 292 | 292 | os.AF_INET6 => { |
| 293 | 293 | const port = mem.bigToNative(u16, self.in6.port); |
| 294 | if (mem.eql(u8, self.in6.addr[0..12], [_]u8{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff })) { | |
| 294 | if (mem.eql(u8, self.in6.addr[0..12], &[_]u8{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff })) { | |
| 295 | 295 | try std.fmt.format( |
| 296 | 296 | context, |
| 297 | 297 | Errors, |
| ... | ... | @@ -339,7 +339,7 @@ pub const Address = extern union { |
| 339 | 339 | unreachable; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | try std.fmt.format(context, Errors, output, "{}", self.un.path); | |
| 342 | try std.fmt.format(context, Errors, output, "{}", &self.un.path); | |
| 343 | 343 | }, |
| 344 | 344 | else => unreachable, |
| 345 | 345 | } |
| ... | ... | @@ -894,7 +894,7 @@ fn linuxLookupNameFromDnsSearch( |
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | const search = if (rc.search.isNull() or dots >= rc.ndots or mem.endsWith(u8, name, ".")) |
| 897 | [_]u8{} | |
| 897 | &[_]u8{} | |
| 898 | 898 | else |
| 899 | 899 | rc.search.toSliceConst(); |
| 900 | 900 | |
| ... | ... | @@ -959,7 +959,7 @@ fn linuxLookupNameFromDns( |
| 959 | 959 | |
| 960 | 960 | for (afrrs) |afrr| { |
| 961 | 961 | if (family != afrr.af) { |
| 962 | const len = os.res_mkquery(0, name, 1, afrr.rr, [_]u8{}, null, &qbuf[nq]); | |
| 962 | const len = os.res_mkquery(0, name, 1, afrr.rr, &[_]u8{}, null, &qbuf[nq]); | |
| 963 | 963 | qp[nq] = qbuf[nq][0..len]; |
| 964 | 964 | nq += 1; |
| 965 | 965 | } |
lib/std/os/test.zig+1-1| ... | ... | @@ -137,7 +137,7 @@ test "getrandom" { |
| 137 | 137 | try os.getrandom(&buf_b); |
| 138 | 138 | // If this test fails the chance is significantly higher that there is a bug than |
| 139 | 139 | // that two sets of 50 bytes were equal. |
| 140 | expect(!mem.eql(u8, buf_a, buf_b)); | |
| 140 | expect(!mem.eql(u8, &buf_a, &buf_b)); | |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | test "getcwd" { |
lib/std/packed_int_array.zig+3-21| ... | ... | @@ -201,7 +201,7 @@ pub fn PackedIntArrayEndian(comptime Int: type, comptime endian: builtin.Endian, |
| 201 | 201 | ///Return the Int stored at index |
| 202 | 202 | pub fn get(self: Self, index: usize) Int { |
| 203 | 203 | debug.assert(index < int_count); |
| 204 | return Io.get(self.bytes, index, 0); | |
| 204 | return Io.get(&self.bytes, index, 0); | |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | ///Copy int into the array at index |
| ... | ... | @@ -528,16 +528,7 @@ test "PackedInt(Array/Slice) sliceCast" { |
| 528 | 528 | test "PackedInt(Array/Slice)Endian" { |
| 529 | 529 | { |
| 530 | 530 | const PackedArrayBe = PackedIntArrayEndian(u4, .Big, 8); |
| 531 | var packed_array_be = PackedArrayBe.init([_]u4{ | |
| 532 | 0, | |
| 533 | 1, | |
| 534 | 2, | |
| 535 | 3, | |
| 536 | 4, | |
| 537 | 5, | |
| 538 | 6, | |
| 539 | 7, | |
| 540 | }); | |
| 531 | var packed_array_be = PackedArrayBe.init([_]u4{ 0, 1, 2, 3, 4, 5, 6, 7 }); | |
| 541 | 532 | testing.expect(packed_array_be.bytes[0] == 0b00000001); |
| 542 | 533 | testing.expect(packed_array_be.bytes[1] == 0b00100011); |
| 543 | 534 | |
| ... | ... | @@ -563,16 +554,7 @@ test "PackedInt(Array/Slice)Endian" { |
| 563 | 554 | |
| 564 | 555 | { |
| 565 | 556 | const PackedArrayBe = PackedIntArrayEndian(u11, .Big, 8); |
| 566 | var packed_array_be = PackedArrayBe.init([_]u11{ | |
| 567 | 0, | |
| 568 | 1, | |
| 569 | 2, | |
| 570 | 3, | |
| 571 | 4, | |
| 572 | 5, | |
| 573 | 6, | |
| 574 | 7, | |
| 575 | }); | |
| 557 | var packed_array_be = PackedArrayBe.init([_]u11{ 0, 1, 2, 3, 4, 5, 6, 7 }); | |
| 576 | 558 | testing.expect(packed_array_be.bytes[0] == 0b00000000); |
| 577 | 559 | testing.expect(packed_array_be.bytes[1] == 0b00000000); |
| 578 | 560 | testing.expect(packed_array_be.bytes[2] == 0b00000100); |
lib/std/priority_queue.zig+1-1| ... | ... | @@ -22,7 +22,7 @@ pub fn PriorityQueue(comptime T: type) type { |
| 22 | 22 | /// `fn lessThan(a: T, b: T) bool { return a < b; }` |
| 23 | 23 | pub fn init(allocator: *Allocator, compareFn: fn (a: T, b: T) bool) Self { |
| 24 | 24 | return Self{ |
| 25 | .items = [_]T{}, | |
| 25 | .items = &[_]T{}, | |
| 26 | 26 | .len = 0, |
| 27 | 27 | .allocator = allocator, |
| 28 | 28 | .compareFn = compareFn, |
lib/std/process.zig+8-8| ... | ... | @@ -473,14 +473,14 @@ pub fn argsFree(allocator: *mem.Allocator, args_alloc: []const []u8) void { |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | test "windows arg parsing" { |
| 476 | testWindowsCmdLine("a b\tc d", [_][]const u8{ "a", "b", "c", "d" }); | |
| 477 | testWindowsCmdLine("\"abc\" d e", [_][]const u8{ "abc", "d", "e" }); | |
| 478 | testWindowsCmdLine("a\\\\\\b d\"e f\"g h", [_][]const u8{ "a\\\\\\b", "de fg", "h" }); | |
| 479 | testWindowsCmdLine("a\\\\\\\"b c d", [_][]const u8{ "a\\\"b", "c", "d" }); | |
| 480 | testWindowsCmdLine("a\\\\\\\\\"b c\" d e", [_][]const u8{ "a\\\\b c", "d", "e" }); | |
| 481 | testWindowsCmdLine("a b\tc \"d f", [_][]const u8{ "a", "b", "c", "\"d", "f" }); | |
| 482 | ||
| 483 | testWindowsCmdLine("\".\\..\\zig-cache\\build\" \"bin\\zig.exe\" \".\\..\" \".\\..\\zig-cache\" \"--help\"", [_][]const u8{ | |
| 476 | testWindowsCmdLine("a b\tc d", &[_][]const u8{ "a", "b", "c", "d" }); | |
| 477 | testWindowsCmdLine("\"abc\" d e", &[_][]const u8{ "abc", "d", "e" }); | |
| 478 | testWindowsCmdLine("a\\\\\\b d\"e f\"g h", &[_][]const u8{ "a\\\\\\b", "de fg", "h" }); | |
| 479 | testWindowsCmdLine("a\\\\\\\"b c d", &[_][]const u8{ "a\\\"b", "c", "d" }); | |
| 480 | testWindowsCmdLine("a\\\\\\\\\"b c\" d e", &[_][]const u8{ "a\\\\b c", "d", "e" }); | |
| 481 | testWindowsCmdLine("a b\tc \"d f", &[_][]const u8{ "a", "b", "c", "\"d", "f" }); | |
| 482 | ||
| 483 | testWindowsCmdLine("\".\\..\\zig-cache\\build\" \"bin\\zig.exe\" \".\\..\" \".\\..\\zig-cache\" \"--help\"", &[_][]const u8{ | |
| 484 | 484 | ".\\..\\zig-cache\\build", |
| 485 | 485 | "bin\\zig.exe", |
| 486 | 486 | ".\\..", |
lib/std/rand.zig+1-1| ... | ... | @@ -54,7 +54,7 @@ pub const Random = struct { |
| 54 | 54 | // use LE instead of native endian for better portability maybe? |
| 55 | 55 | // TODO: endian portability is pointless if the underlying prng isn't endian portable. |
| 56 | 56 | // TODO: document the endian portability of this library. |
| 57 | const byte_aligned_result = mem.readIntSliceLittle(ByteAlignedT, rand_bytes); | |
| 57 | const byte_aligned_result = mem.readIntSliceLittle(ByteAlignedT, &rand_bytes); | |
| 58 | 58 | const unsigned_result = @truncate(UnsignedT, byte_aligned_result); |
| 59 | 59 | return @bitCast(T, unsigned_result); |
| 60 | 60 | } |
lib/std/segmented_list.zig+4-8| ... | ... | @@ -112,7 +112,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type |
| 112 | 112 | .allocator = allocator, |
| 113 | 113 | .len = 0, |
| 114 | 114 | .prealloc_segment = undefined, |
| 115 | .dynamic_segments = [_][*]T{}, | |
| 115 | .dynamic_segments = &[_][*]T{}, | |
| 116 | 116 | }; |
| 117 | 117 | } |
| 118 | 118 | |
| ... | ... | @@ -192,7 +192,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type |
| 192 | 192 | const len = @intCast(ShelfIndex, self.dynamic_segments.len); |
| 193 | 193 | self.freeShelves(len, 0); |
| 194 | 194 | self.allocator.free(self.dynamic_segments); |
| 195 | self.dynamic_segments = [_][*]T{}; | |
| 195 | self.dynamic_segments = &[_][*]T{}; | |
| 196 | 196 | return; |
| 197 | 197 | } |
| 198 | 198 | |
| ... | ... | @@ -385,18 +385,14 @@ fn testSegmentedList(comptime prealloc: usize, allocator: *Allocator) !void { |
| 385 | 385 | testing.expect(list.pop().? == 100); |
| 386 | 386 | testing.expect(list.len == 99); |
| 387 | 387 | |
| 388 | try list.pushMany([_]i32{ | |
| 389 | 1, | |
| 390 | 2, | |
| 391 | 3, | |
| 392 | }); | |
| 388 | try list.pushMany(&[_]i32{ 1, 2, 3 }); | |
| 393 | 389 | testing.expect(list.len == 102); |
| 394 | 390 | testing.expect(list.pop().? == 3); |
| 395 | 391 | testing.expect(list.pop().? == 2); |
| 396 | 392 | testing.expect(list.pop().? == 1); |
| 397 | 393 | testing.expect(list.len == 99); |
| 398 | 394 | |
| 399 | try list.pushMany([_]i32{}); | |
| 395 | try list.pushMany(&[_]i32{}); | |
| 400 | 396 | testing.expect(list.len == 99); |
| 401 | 397 | |
| 402 | 398 | var i: i32 = 99; |
lib/std/sort.zig+43-43| ... | ... | @@ -1043,27 +1043,27 @@ fn cmpByValue(a: IdAndValue, b: IdAndValue) bool { |
| 1043 | 1043 | |
| 1044 | 1044 | test "std.sort" { |
| 1045 | 1045 | const u8cases = [_][]const []const u8{ |
| 1046 | [_][]const u8{ | |
| 1046 | &[_][]const u8{ | |
| 1047 | 1047 | "", |
| 1048 | 1048 | "", |
| 1049 | 1049 | }, |
| 1050 | [_][]const u8{ | |
| 1050 | &[_][]const u8{ | |
| 1051 | 1051 | "a", |
| 1052 | 1052 | "a", |
| 1053 | 1053 | }, |
| 1054 | [_][]const u8{ | |
| 1054 | &[_][]const u8{ | |
| 1055 | 1055 | "az", |
| 1056 | 1056 | "az", |
| 1057 | 1057 | }, |
| 1058 | [_][]const u8{ | |
| 1058 | &[_][]const u8{ | |
| 1059 | 1059 | "za", |
| 1060 | 1060 | "az", |
| 1061 | 1061 | }, |
| 1062 | [_][]const u8{ | |
| 1062 | &[_][]const u8{ | |
| 1063 | 1063 | "asdf", |
| 1064 | 1064 | "adfs", |
| 1065 | 1065 | }, |
| 1066 | [_][]const u8{ | |
| 1066 | &[_][]const u8{ | |
| 1067 | 1067 | "one", |
| 1068 | 1068 | "eno", |
| 1069 | 1069 | }, |
| ... | ... | @@ -1078,29 +1078,29 @@ test "std.sort" { |
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | 1080 | const i32cases = [_][]const []const i32{ |
| 1081 | [_][]const i32{ | |
| 1082 | [_]i32{}, | |
| 1083 | [_]i32{}, | |
| 1081 | &[_][]const i32{ | |
| 1082 | &[_]i32{}, | |
| 1083 | &[_]i32{}, | |
| 1084 | 1084 | }, |
| 1085 | [_][]const i32{ | |
| 1086 | [_]i32{1}, | |
| 1087 | [_]i32{1}, | |
| 1085 | &[_][]const i32{ | |
| 1086 | &[_]i32{1}, | |
| 1087 | &[_]i32{1}, | |
| 1088 | 1088 | }, |
| 1089 | [_][]const i32{ | |
| 1090 | [_]i32{ 0, 1 }, | |
| 1091 | [_]i32{ 0, 1 }, | |
| 1089 | &[_][]const i32{ | |
| 1090 | &[_]i32{ 0, 1 }, | |
| 1091 | &[_]i32{ 0, 1 }, | |
| 1092 | 1092 | }, |
| 1093 | [_][]const i32{ | |
| 1094 | [_]i32{ 1, 0 }, | |
| 1095 | [_]i32{ 0, 1 }, | |
| 1093 | &[_][]const i32{ | |
| 1094 | &[_]i32{ 1, 0 }, | |
| 1095 | &[_]i32{ 0, 1 }, | |
| 1096 | 1096 | }, |
| 1097 | [_][]const i32{ | |
| 1098 | [_]i32{ 1, -1, 0 }, | |
| 1099 | [_]i32{ -1, 0, 1 }, | |
| 1097 | &[_][]const i32{ | |
| 1098 | &[_]i32{ 1, -1, 0 }, | |
| 1099 | &[_]i32{ -1, 0, 1 }, | |
| 1100 | 1100 | }, |
| 1101 | [_][]const i32{ | |
| 1102 | [_]i32{ 2, 1, 3 }, | |
| 1103 | [_]i32{ 1, 2, 3 }, | |
| 1101 | &[_][]const i32{ | |
| 1102 | &[_]i32{ 2, 1, 3 }, | |
| 1103 | &[_]i32{ 1, 2, 3 }, | |
| 1104 | 1104 | }, |
| 1105 | 1105 | }; |
| 1106 | 1106 | |
| ... | ... | @@ -1115,29 +1115,29 @@ test "std.sort" { |
| 1115 | 1115 | |
| 1116 | 1116 | test "std.sort descending" { |
| 1117 | 1117 | const rev_cases = [_][]const []const i32{ |
| 1118 | [_][]const i32{ | |
| 1119 | [_]i32{}, | |
| 1120 | [_]i32{}, | |
| 1118 | &[_][]const i32{ | |
| 1119 | &[_]i32{}, | |
| 1120 | &[_]i32{}, | |
| 1121 | 1121 | }, |
| 1122 | [_][]const i32{ | |
| 1123 | [_]i32{1}, | |
| 1124 | [_]i32{1}, | |
| 1122 | &[_][]const i32{ | |
| 1123 | &[_]i32{1}, | |
| 1124 | &[_]i32{1}, | |
| 1125 | 1125 | }, |
| 1126 | [_][]const i32{ | |
| 1127 | [_]i32{ 0, 1 }, | |
| 1128 | [_]i32{ 1, 0 }, | |
| 1126 | &[_][]const i32{ | |
| 1127 | &[_]i32{ 0, 1 }, | |
| 1128 | &[_]i32{ 1, 0 }, | |
| 1129 | 1129 | }, |
| 1130 | [_][]const i32{ | |
| 1131 | [_]i32{ 1, 0 }, | |
| 1132 | [_]i32{ 1, 0 }, | |
| 1130 | &[_][]const i32{ | |
| 1131 | &[_]i32{ 1, 0 }, | |
| 1132 | &[_]i32{ 1, 0 }, | |
| 1133 | 1133 | }, |
| 1134 | [_][]const i32{ | |
| 1135 | [_]i32{ 1, -1, 0 }, | |
| 1136 | [_]i32{ 1, 0, -1 }, | |
| 1134 | &[_][]const i32{ | |
| 1135 | &[_]i32{ 1, -1, 0 }, | |
| 1136 | &[_]i32{ 1, 0, -1 }, | |
| 1137 | 1137 | }, |
| 1138 | [_][]const i32{ | |
| 1139 | [_]i32{ 2, 1, 3 }, | |
| 1140 | [_]i32{ 3, 2, 1 }, | |
| 1138 | &[_][]const i32{ | |
| 1139 | &[_]i32{ 2, 1, 3 }, | |
| 1140 | &[_]i32{ 3, 2, 1 }, | |
| 1141 | 1141 | }, |
| 1142 | 1142 | }; |
| 1143 | 1143 | |
| ... | ... | @@ -1154,7 +1154,7 @@ test "another sort case" { |
| 1154 | 1154 | var arr = [_]i32{ 5, 3, 1, 2, 4 }; |
| 1155 | 1155 | sort(i32, arr[0..], asc(i32)); |
| 1156 | 1156 | |
| 1157 | testing.expect(mem.eql(i32, arr, [_]i32{ 1, 2, 3, 4, 5 })); | |
| 1157 | testing.expect(mem.eql(i32, &arr, &[_]i32{ 1, 2, 3, 4, 5 })); | |
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | 1160 | test "sort fuzz testing" { |
lib/std/unicode.zig+6-6| ... | ... | @@ -499,14 +499,14 @@ test "utf16leToUtf8" { |
| 499 | 499 | { |
| 500 | 500 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 'A'); |
| 501 | 501 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 'a'); |
| 502 | const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, utf16le); | |
| 502 | const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, &utf16le); | |
| 503 | 503 | testing.expect(mem.eql(u8, utf8, "Aa")); |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | { |
| 507 | 507 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0x80); |
| 508 | 508 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xffff); |
| 509 | const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, utf16le); | |
| 509 | const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, &utf16le); | |
| 510 | 510 | testing.expect(mem.eql(u8, utf8, "\xc2\x80" ++ "\xef\xbf\xbf")); |
| 511 | 511 | } |
| 512 | 512 | |
| ... | ... | @@ -514,7 +514,7 @@ test "utf16leToUtf8" { |
| 514 | 514 | // the values just outside the surrogate half range |
| 515 | 515 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xd7ff); |
| 516 | 516 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xe000); |
| 517 | const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, utf16le); | |
| 517 | const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, &utf16le); | |
| 518 | 518 | testing.expect(mem.eql(u8, utf8, "\xed\x9f\xbf" ++ "\xee\x80\x80")); |
| 519 | 519 | } |
| 520 | 520 | |
| ... | ... | @@ -522,7 +522,7 @@ test "utf16leToUtf8" { |
| 522 | 522 | // smallest surrogate pair |
| 523 | 523 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xd800); |
| 524 | 524 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xdc00); |
| 525 | const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, utf16le); | |
| 525 | const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, &utf16le); | |
| 526 | 526 | testing.expect(mem.eql(u8, utf8, "\xf0\x90\x80\x80")); |
| 527 | 527 | } |
| 528 | 528 | |
| ... | ... | @@ -530,14 +530,14 @@ test "utf16leToUtf8" { |
| 530 | 530 | // largest surrogate pair |
| 531 | 531 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xdbff); |
| 532 | 532 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xdfff); |
| 533 | const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, utf16le); | |
| 533 | const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, &utf16le); | |
| 534 | 534 | testing.expect(mem.eql(u8, utf8, "\xf4\x8f\xbf\xbf")); |
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | { |
| 538 | 538 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xdbff); |
| 539 | 539 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xdc00); |
| 540 | const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, utf16le); | |
| 540 | const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, &utf16le); | |
| 541 | 541 | testing.expect(mem.eql(u8, utf8, "\xf4\x8f\xb0\x80")); |
| 542 | 542 | } |
| 543 | 543 | } |
lib/std/zig/tokenizer.zig+61-61| ... | ... | @@ -1313,14 +1313,14 @@ pub const Tokenizer = struct { |
| 1313 | 1313 | }; |
| 1314 | 1314 | |
| 1315 | 1315 | test "tokenizer" { |
| 1316 | testTokenize("test", [_]Token.Id{Token.Id.Keyword_test}); | |
| 1316 | testTokenize("test", &[_]Token.Id{Token.Id.Keyword_test}); | |
| 1317 | 1317 | } |
| 1318 | 1318 | |
| 1319 | 1319 | test "tokenizer - unknown length pointer and then c pointer" { |
| 1320 | 1320 | testTokenize( |
| 1321 | 1321 | \\[*]u8 |
| 1322 | 1322 | \\[*c]u8 |
| 1323 | , [_]Token.Id{ | |
| 1323 | , &[_]Token.Id{ | |
| 1324 | 1324 | Token.Id.LBracket, |
| 1325 | 1325 | Token.Id.Asterisk, |
| 1326 | 1326 | Token.Id.RBracket, |
| ... | ... | @@ -1336,70 +1336,70 @@ test "tokenizer - unknown length pointer and then c pointer" { |
| 1336 | 1336 | test "tokenizer - char literal with hex escape" { |
| 1337 | 1337 | testTokenize( |
| 1338 | 1338 | \\'\x1b' |
| 1339 | , [_]Token.Id{.CharLiteral}); | |
| 1339 | , &[_]Token.Id{.CharLiteral}); | |
| 1340 | 1340 | testTokenize( |
| 1341 | 1341 | \\'\x1' |
| 1342 | , [_]Token.Id{ .Invalid, .Invalid }); | |
| 1342 | , &[_]Token.Id{ .Invalid, .Invalid }); | |
| 1343 | 1343 | } |
| 1344 | 1344 | |
| 1345 | 1345 | test "tokenizer - char literal with unicode escapes" { |
| 1346 | 1346 | // Valid unicode escapes |
| 1347 | 1347 | testTokenize( |
| 1348 | 1348 | \\'\u{3}' |
| 1349 | , [_]Token.Id{.CharLiteral}); | |
| 1349 | , &[_]Token.Id{.CharLiteral}); | |
| 1350 | 1350 | testTokenize( |
| 1351 | 1351 | \\'\u{01}' |
| 1352 | , [_]Token.Id{.CharLiteral}); | |
| 1352 | , &[_]Token.Id{.CharLiteral}); | |
| 1353 | 1353 | testTokenize( |
| 1354 | 1354 | \\'\u{2a}' |
| 1355 | , [_]Token.Id{.CharLiteral}); | |
| 1355 | , &[_]Token.Id{.CharLiteral}); | |
| 1356 | 1356 | testTokenize( |
| 1357 | 1357 | \\'\u{3f9}' |
| 1358 | , [_]Token.Id{.CharLiteral}); | |
| 1358 | , &[_]Token.Id{.CharLiteral}); | |
| 1359 | 1359 | testTokenize( |
| 1360 | 1360 | \\'\u{6E09aBc1523}' |
| 1361 | , [_]Token.Id{.CharLiteral}); | |
| 1361 | , &[_]Token.Id{.CharLiteral}); | |
| 1362 | 1362 | testTokenize( |
| 1363 | 1363 | \\"\u{440}" |
| 1364 | , [_]Token.Id{.StringLiteral}); | |
| 1364 | , &[_]Token.Id{.StringLiteral}); | |
| 1365 | 1365 | |
| 1366 | 1366 | // Invalid unicode escapes |
| 1367 | 1367 | testTokenize( |
| 1368 | 1368 | \\'\u' |
| 1369 | , [_]Token.Id{.Invalid}); | |
| 1369 | , &[_]Token.Id{.Invalid}); | |
| 1370 | 1370 | testTokenize( |
| 1371 | 1371 | \\'\u{{' |
| 1372 | , [_]Token.Id{ .Invalid, .Invalid }); | |
| 1372 | , &[_]Token.Id{ .Invalid, .Invalid }); | |
| 1373 | 1373 | testTokenize( |
| 1374 | 1374 | \\'\u{}' |
| 1375 | , [_]Token.Id{ .Invalid, .Invalid }); | |
| 1375 | , &[_]Token.Id{ .Invalid, .Invalid }); | |
| 1376 | 1376 | testTokenize( |
| 1377 | 1377 | \\'\u{s}' |
| 1378 | , [_]Token.Id{ .Invalid, .Invalid }); | |
| 1378 | , &[_]Token.Id{ .Invalid, .Invalid }); | |
| 1379 | 1379 | testTokenize( |
| 1380 | 1380 | \\'\u{2z}' |
| 1381 | , [_]Token.Id{ .Invalid, .Invalid }); | |
| 1381 | , &[_]Token.Id{ .Invalid, .Invalid }); | |
| 1382 | 1382 | testTokenize( |
| 1383 | 1383 | \\'\u{4a' |
| 1384 | , [_]Token.Id{.Invalid}); | |
| 1384 | , &[_]Token.Id{.Invalid}); | |
| 1385 | 1385 | |
| 1386 | 1386 | // Test old-style unicode literals |
| 1387 | 1387 | testTokenize( |
| 1388 | 1388 | \\'\u0333' |
| 1389 | , [_]Token.Id{ .Invalid, .Invalid }); | |
| 1389 | , &[_]Token.Id{ .Invalid, .Invalid }); | |
| 1390 | 1390 | testTokenize( |
| 1391 | 1391 | \\'\U0333' |
| 1392 | , [_]Token.Id{ .Invalid, .IntegerLiteral, .Invalid }); | |
| 1392 | , &[_]Token.Id{ .Invalid, .IntegerLiteral, .Invalid }); | |
| 1393 | 1393 | } |
| 1394 | 1394 | |
| 1395 | 1395 | test "tokenizer - char literal with unicode code point" { |
| 1396 | 1396 | testTokenize( |
| 1397 | 1397 | \\'💩' |
| 1398 | , [_]Token.Id{.CharLiteral}); | |
| 1398 | , &[_]Token.Id{.CharLiteral}); | |
| 1399 | 1399 | } |
| 1400 | 1400 | |
| 1401 | 1401 | test "tokenizer - float literal e exponent" { |
| 1402 | testTokenize("a = 4.94065645841246544177e-324;\n", [_]Token.Id{ | |
| 1402 | testTokenize("a = 4.94065645841246544177e-324;\n", &[_]Token.Id{ | |
| 1403 | 1403 | Token.Id.Identifier, |
| 1404 | 1404 | Token.Id.Equal, |
| 1405 | 1405 | Token.Id.FloatLiteral, |
| ... | ... | @@ -1408,7 +1408,7 @@ test "tokenizer - float literal e exponent" { |
| 1408 | 1408 | } |
| 1409 | 1409 | |
| 1410 | 1410 | test "tokenizer - float literal p exponent" { |
| 1411 | testTokenize("a = 0x1.a827999fcef32p+1022;\n", [_]Token.Id{ | |
| 1411 | testTokenize("a = 0x1.a827999fcef32p+1022;\n", &[_]Token.Id{ | |
| 1412 | 1412 | Token.Id.Identifier, |
| 1413 | 1413 | Token.Id.Equal, |
| 1414 | 1414 | Token.Id.FloatLiteral, |
| ... | ... | @@ -1417,71 +1417,71 @@ test "tokenizer - float literal p exponent" { |
| 1417 | 1417 | } |
| 1418 | 1418 | |
| 1419 | 1419 | test "tokenizer - chars" { |
| 1420 | testTokenize("'c'", [_]Token.Id{Token.Id.CharLiteral}); | |
| 1420 | testTokenize("'c'", &[_]Token.Id{Token.Id.CharLiteral}); | |
| 1421 | 1421 | } |
| 1422 | 1422 | |
| 1423 | 1423 | test "tokenizer - invalid token characters" { |
| 1424 | testTokenize("#", [_]Token.Id{Token.Id.Invalid}); | |
| 1425 | testTokenize("`", [_]Token.Id{Token.Id.Invalid}); | |
| 1426 | testTokenize("'c", [_]Token.Id{Token.Id.Invalid}); | |
| 1427 | testTokenize("'", [_]Token.Id{Token.Id.Invalid}); | |
| 1428 | testTokenize("''", [_]Token.Id{ Token.Id.Invalid, Token.Id.Invalid }); | |
| 1424 | testTokenize("#", &[_]Token.Id{Token.Id.Invalid}); | |
| 1425 | testTokenize("`", &[_]Token.Id{Token.Id.Invalid}); | |
| 1426 | testTokenize("'c", &[_]Token.Id{Token.Id.Invalid}); | |
| 1427 | testTokenize("'", &[_]Token.Id{Token.Id.Invalid}); | |
| 1428 | testTokenize("''", &[_]Token.Id{ Token.Id.Invalid, Token.Id.Invalid }); | |
| 1429 | 1429 | } |
| 1430 | 1430 | |
| 1431 | 1431 | test "tokenizer - invalid literal/comment characters" { |
| 1432 | testTokenize("\"\x00\"", [_]Token.Id{ | |
| 1432 | testTokenize("\"\x00\"", &[_]Token.Id{ | |
| 1433 | 1433 | Token.Id.StringLiteral, |
| 1434 | 1434 | Token.Id.Invalid, |
| 1435 | 1435 | }); |
| 1436 | testTokenize("//\x00", [_]Token.Id{ | |
| 1436 | testTokenize("//\x00", &[_]Token.Id{ | |
| 1437 | 1437 | Token.Id.LineComment, |
| 1438 | 1438 | Token.Id.Invalid, |
| 1439 | 1439 | }); |
| 1440 | testTokenize("//\x1f", [_]Token.Id{ | |
| 1440 | testTokenize("//\x1f", &[_]Token.Id{ | |
| 1441 | 1441 | Token.Id.LineComment, |
| 1442 | 1442 | Token.Id.Invalid, |
| 1443 | 1443 | }); |
| 1444 | testTokenize("//\x7f", [_]Token.Id{ | |
| 1444 | testTokenize("//\x7f", &[_]Token.Id{ | |
| 1445 | 1445 | Token.Id.LineComment, |
| 1446 | 1446 | Token.Id.Invalid, |
| 1447 | 1447 | }); |
| 1448 | 1448 | } |
| 1449 | 1449 | |
| 1450 | 1450 | test "tokenizer - utf8" { |
| 1451 | testTokenize("//\xc2\x80", [_]Token.Id{Token.Id.LineComment}); | |
| 1452 | testTokenize("//\xf4\x8f\xbf\xbf", [_]Token.Id{Token.Id.LineComment}); | |
| 1451 | testTokenize("//\xc2\x80", &[_]Token.Id{Token.Id.LineComment}); | |
| 1452 | testTokenize("//\xf4\x8f\xbf\xbf", &[_]Token.Id{Token.Id.LineComment}); | |
| 1453 | 1453 | } |
| 1454 | 1454 | |
| 1455 | 1455 | test "tokenizer - invalid utf8" { |
| 1456 | testTokenize("//\x80", [_]Token.Id{ | |
| 1456 | testTokenize("//\x80", &[_]Token.Id{ | |
| 1457 | 1457 | Token.Id.LineComment, |
| 1458 | 1458 | Token.Id.Invalid, |
| 1459 | 1459 | }); |
| 1460 | testTokenize("//\xbf", [_]Token.Id{ | |
| 1460 | testTokenize("//\xbf", &[_]Token.Id{ | |
| 1461 | 1461 | Token.Id.LineComment, |
| 1462 | 1462 | Token.Id.Invalid, |
| 1463 | 1463 | }); |
| 1464 | testTokenize("//\xf8", [_]Token.Id{ | |
| 1464 | testTokenize("//\xf8", &[_]Token.Id{ | |
| 1465 | 1465 | Token.Id.LineComment, |
| 1466 | 1466 | Token.Id.Invalid, |
| 1467 | 1467 | }); |
| 1468 | testTokenize("//\xff", [_]Token.Id{ | |
| 1468 | testTokenize("//\xff", &[_]Token.Id{ | |
| 1469 | 1469 | Token.Id.LineComment, |
| 1470 | 1470 | Token.Id.Invalid, |
| 1471 | 1471 | }); |
| 1472 | testTokenize("//\xc2\xc0", [_]Token.Id{ | |
| 1472 | testTokenize("//\xc2\xc0", &[_]Token.Id{ | |
| 1473 | 1473 | Token.Id.LineComment, |
| 1474 | 1474 | Token.Id.Invalid, |
| 1475 | 1475 | }); |
| 1476 | testTokenize("//\xe0", [_]Token.Id{ | |
| 1476 | testTokenize("//\xe0", &[_]Token.Id{ | |
| 1477 | 1477 | Token.Id.LineComment, |
| 1478 | 1478 | Token.Id.Invalid, |
| 1479 | 1479 | }); |
| 1480 | testTokenize("//\xf0", [_]Token.Id{ | |
| 1480 | testTokenize("//\xf0", &[_]Token.Id{ | |
| 1481 | 1481 | Token.Id.LineComment, |
| 1482 | 1482 | Token.Id.Invalid, |
| 1483 | 1483 | }); |
| 1484 | testTokenize("//\xf0\x90\x80\xc0", [_]Token.Id{ | |
| 1484 | testTokenize("//\xf0\x90\x80\xc0", &[_]Token.Id{ | |
| 1485 | 1485 | Token.Id.LineComment, |
| 1486 | 1486 | Token.Id.Invalid, |
| 1487 | 1487 | }); |
| ... | ... | @@ -1489,28 +1489,28 @@ test "tokenizer - invalid utf8" { |
| 1489 | 1489 | |
| 1490 | 1490 | test "tokenizer - illegal unicode codepoints" { |
| 1491 | 1491 | // unicode newline characters.U+0085, U+2028, U+2029 |
| 1492 | testTokenize("//\xc2\x84", [_]Token.Id{Token.Id.LineComment}); | |
| 1493 | testTokenize("//\xc2\x85", [_]Token.Id{ | |
| 1492 | testTokenize("//\xc2\x84", &[_]Token.Id{Token.Id.LineComment}); | |
| 1493 | testTokenize("//\xc2\x85", &[_]Token.Id{ | |
| 1494 | 1494 | Token.Id.LineComment, |
| 1495 | 1495 | Token.Id.Invalid, |
| 1496 | 1496 | }); |
| 1497 | testTokenize("//\xc2\x86", [_]Token.Id{Token.Id.LineComment}); | |
| 1498 | testTokenize("//\xe2\x80\xa7", [_]Token.Id{Token.Id.LineComment}); | |
| 1499 | testTokenize("//\xe2\x80\xa8", [_]Token.Id{ | |
| 1497 | testTokenize("//\xc2\x86", &[_]Token.Id{Token.Id.LineComment}); | |
| 1498 | testTokenize("//\xe2\x80\xa7", &[_]Token.Id{Token.Id.LineComment}); | |
| 1499 | testTokenize("//\xe2\x80\xa8", &[_]Token.Id{ | |
| 1500 | 1500 | Token.Id.LineComment, |
| 1501 | 1501 | Token.Id.Invalid, |
| 1502 | 1502 | }); |
| 1503 | testTokenize("//\xe2\x80\xa9", [_]Token.Id{ | |
| 1503 | testTokenize("//\xe2\x80\xa9", &[_]Token.Id{ | |
| 1504 | 1504 | Token.Id.LineComment, |
| 1505 | 1505 | Token.Id.Invalid, |
| 1506 | 1506 | }); |
| 1507 | testTokenize("//\xe2\x80\xaa", [_]Token.Id{Token.Id.LineComment}); | |
| 1507 | testTokenize("//\xe2\x80\xaa", &[_]Token.Id{Token.Id.LineComment}); | |
| 1508 | 1508 | } |
| 1509 | 1509 | |
| 1510 | 1510 | test "tokenizer - string identifier and builtin fns" { |
| 1511 | 1511 | testTokenize( |
| 1512 | 1512 | \\const @"if" = @import("std"); |
| 1513 | , [_]Token.Id{ | |
| 1513 | , &[_]Token.Id{ | |
| 1514 | 1514 | Token.Id.Keyword_const, |
| 1515 | 1515 | Token.Id.Identifier, |
| 1516 | 1516 | Token.Id.Equal, |
| ... | ... | @@ -1523,21 +1523,21 @@ test "tokenizer - string identifier and builtin fns" { |
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | 1525 | test "tokenizer - pipe and then invalid" { |
| 1526 | testTokenize("||=", [_]Token.Id{ | |
| 1526 | testTokenize("||=", &[_]Token.Id{ | |
| 1527 | 1527 | Token.Id.PipePipe, |
| 1528 | 1528 | Token.Id.Equal, |
| 1529 | 1529 | }); |
| 1530 | 1530 | } |
| 1531 | 1531 | |
| 1532 | 1532 | test "tokenizer - line comment and doc comment" { |
| 1533 | testTokenize("//", [_]Token.Id{Token.Id.LineComment}); | |
| 1534 | testTokenize("// a / b", [_]Token.Id{Token.Id.LineComment}); | |
| 1535 | testTokenize("// /", [_]Token.Id{Token.Id.LineComment}); | |
| 1536 | testTokenize("/// a", [_]Token.Id{Token.Id.DocComment}); | |
| 1537 | testTokenize("///", [_]Token.Id{Token.Id.DocComment}); | |
| 1538 | testTokenize("////", [_]Token.Id{Token.Id.LineComment}); | |
| 1539 | testTokenize("//!", [_]Token.Id{Token.Id.ContainerDocComment}); | |
| 1540 | testTokenize("//!!", [_]Token.Id{Token.Id.ContainerDocComment}); | |
| 1533 | testTokenize("//", &[_]Token.Id{Token.Id.LineComment}); | |
| 1534 | testTokenize("// a / b", &[_]Token.Id{Token.Id.LineComment}); | |
| 1535 | testTokenize("// /", &[_]Token.Id{Token.Id.LineComment}); | |
| 1536 | testTokenize("/// a", &[_]Token.Id{Token.Id.DocComment}); | |
| 1537 | testTokenize("///", &[_]Token.Id{Token.Id.DocComment}); | |
| 1538 | testTokenize("////", &[_]Token.Id{Token.Id.LineComment}); | |
| 1539 | testTokenize("//!", &[_]Token.Id{Token.Id.ContainerDocComment}); | |
| 1540 | testTokenize("//!!", &[_]Token.Id{Token.Id.ContainerDocComment}); | |
| 1541 | 1541 | } |
| 1542 | 1542 | |
| 1543 | 1543 | test "tokenizer - line comment followed by identifier" { |
| ... | ... | @@ -1545,7 +1545,7 @@ test "tokenizer - line comment followed by identifier" { |
| 1545 | 1545 | \\ Unexpected, |
| 1546 | 1546 | \\ // another |
| 1547 | 1547 | \\ Another, |
| 1548 | , [_]Token.Id{ | |
| 1548 | , &[_]Token.Id{ | |
| 1549 | 1549 | Token.Id.Identifier, |
| 1550 | 1550 | Token.Id.Comma, |
| 1551 | 1551 | Token.Id.LineComment, |
| ... | ... | @@ -1555,14 +1555,14 @@ test "tokenizer - line comment followed by identifier" { |
| 1555 | 1555 | } |
| 1556 | 1556 | |
| 1557 | 1557 | test "tokenizer - UTF-8 BOM is recognized and skipped" { |
| 1558 | testTokenize("\xEF\xBB\xBFa;\n", [_]Token.Id{ | |
| 1558 | testTokenize("\xEF\xBB\xBFa;\n", &[_]Token.Id{ | |
| 1559 | 1559 | Token.Id.Identifier, |
| 1560 | 1560 | Token.Id.Semicolon, |
| 1561 | 1561 | }); |
| 1562 | 1562 | } |
| 1563 | 1563 | |
| 1564 | 1564 | test "correctly parse pointer assignment" { |
| 1565 | testTokenize("b.*=3;\n", [_]Token.Id{ | |
| 1565 | testTokenize("b.*=3;\n", &[_]Token.Id{ | |
| 1566 | 1566 | Token.Id.Identifier, |
| 1567 | 1567 | Token.Id.PeriodAsterisk, |
| 1568 | 1568 | Token.Id.Equal, |
src-self-hosted/dep_tokenizer.zig+2-2| ... | ... | @@ -992,7 +992,7 @@ fn printHexValue(out: var, value: u64, width: u8) !void { |
| 992 | 992 | |
| 993 | 993 | fn printCharValues(out: var, bytes: []const u8) !void { |
| 994 | 994 | for (bytes) |b| { |
| 995 | try out.write([_]u8{printable_char_tab[b]}); | |
| 995 | try out.write(&[_]u8{printable_char_tab[b]}); | |
| 996 | 996 | } |
| 997 | 997 | } |
| 998 | 998 | |
| ... | ... | @@ -1001,7 +1001,7 @@ fn printUnderstandableChar(out: var, char: u8) !void { |
| 1001 | 1001 | std.fmt.format(out.context, anyerror, out.output, "\\x{X:2}", char) catch {}; |
| 1002 | 1002 | } else { |
| 1003 | 1003 | try out.write("'"); |
| 1004 | try out.write([_]u8{printable_char_tab[char]}); | |
| 1004 | try out.write(&[_]u8{printable_char_tab[char]}); | |
| 1005 | 1005 | try out.write("'"); |
| 1006 | 1006 | } |
| 1007 | 1007 | } |
src-self-hosted/main.zig+1-1| ... | ... | @@ -521,7 +521,7 @@ pub const usage_fmt = |
| 521 | 521 | pub const args_fmt_spec = [_]Flag{ |
| 522 | 522 | Flag.Bool("--help"), |
| 523 | 523 | Flag.Bool("--check"), |
| 524 | Flag.Option("--color", [_][]const u8{ | |
| 524 | Flag.Option("--color", &[_][]const u8{ | |
| 525 | 525 | "auto", |
| 526 | 526 | "off", |
| 527 | 527 | "on", |
src-self-hosted/stage1.zig+2-2| ... | ... | @@ -170,7 +170,7 @@ fn fmtMain(argc: c_int, argv: [*]const [*:0]const u8) !void { |
| 170 | 170 | stderr = &stderr_file.outStream().stream; |
| 171 | 171 | |
| 172 | 172 | const args = args_list.toSliceConst(); |
| 173 | var flags = try Args.parse(allocator, self_hosted_main.args_fmt_spec, args[2..]); | |
| 173 | var flags = try Args.parse(allocator, &self_hosted_main.args_fmt_spec, args[2..]); | |
| 174 | 174 | defer flags.deinit(); |
| 175 | 175 | |
| 176 | 176 | if (flags.present("help")) { |
| ... | ... | @@ -286,7 +286,7 @@ fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtError!void |
| 286 | 286 | |
| 287 | 287 | while (try dir_it.next()) |entry| { |
| 288 | 288 | if (entry.kind == .Directory or mem.endsWith(u8, entry.name, ".zig")) { |
| 289 | const full_path = try fs.path.join(fmt.allocator, [_][]const u8{ file_path, entry.name }); | |
| 289 | const full_path = try fs.path.join(fmt.allocator, &[_][]const u8{ file_path, entry.name }); | |
| 290 | 290 | try fmtPath(fmt, full_path, check_mode); |
| 291 | 291 | } |
| 292 | 292 | } |
src/all_types.hpp+3| ... | ... | @@ -2650,6 +2650,9 @@ struct IrInstruction { |
| 2650 | 2650 | IrInstructionId id; |
| 2651 | 2651 | // true if this instruction was generated by zig and not from user code |
| 2652 | 2652 | bool is_gen; |
| 2653 | ||
| 2654 | // for debugging purposes, this is useful to call to inspect the instruction | |
| 2655 | void dump(); | |
| 2653 | 2656 | }; |
| 2654 | 2657 | |
| 2655 | 2658 | struct IrInstructionDeclVarSrc { |
src/ir.cpp+171-265| ... | ... | @@ -218,7 +218,8 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc |
| 218 | 218 | static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, |
| 219 | 219 | ZigType *dest_type); |
| 220 | 220 | static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspend_source_instr, |
| 221 | ResultLoc *result_loc, ZigType *value_type, IrInstruction *value, bool force_runtime, bool non_null_comptime); | |
| 221 | ResultLoc *result_loc, ZigType *value_type, IrInstruction *value, bool force_runtime, | |
| 222 | bool non_null_comptime, bool allow_discard); | |
| 222 | 223 | static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_source_instr, |
| 223 | 224 | ResultLoc *result_loc, ZigType *value_type, IrInstruction *value, bool force_runtime, |
| 224 | 225 | bool non_null_comptime, bool allow_discard); |
| ... | ... | @@ -10417,9 +10418,6 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10417 | 10418 | } |
| 10418 | 10419 | |
| 10419 | 10420 | if (cur_type->id == ZigTypeIdErrorSet) { |
| 10420 | if (prev_type->id == ZigTypeIdArray) { | |
| 10421 | convert_to_const_slice = true; | |
| 10422 | } | |
| 10423 | 10421 | if (!resolve_inferred_error_set(ira->codegen, cur_type, cur_inst->source_node)) { |
| 10424 | 10422 | return ira->codegen->builtin_types.entry_invalid; |
| 10425 | 10423 | } |
| ... | ... | @@ -10754,25 +10752,6 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10754 | 10752 | } |
| 10755 | 10753 | } |
| 10756 | 10754 | |
| 10757 | if (cur_type->id == ZigTypeIdArray && prev_type->id == ZigTypeIdArray && | |
| 10758 | cur_type->data.array.len != prev_type->data.array.len && | |
| 10759 | types_match_const_cast_only(ira, cur_type->data.array.child_type, prev_type->data.array.child_type, | |
| 10760 | source_node, false).id == ConstCastResultIdOk) | |
| 10761 | { | |
| 10762 | convert_to_const_slice = true; | |
| 10763 | prev_inst = cur_inst; | |
| 10764 | continue; | |
| 10765 | } | |
| 10766 | ||
| 10767 | if (cur_type->id == ZigTypeIdArray && prev_type->id == ZigTypeIdArray && | |
| 10768 | cur_type->data.array.len != prev_type->data.array.len && | |
| 10769 | types_match_const_cast_only(ira, prev_type->data.array.child_type, cur_type->data.array.child_type, | |
| 10770 | source_node, false).id == ConstCastResultIdOk) | |
| 10771 | { | |
| 10772 | convert_to_const_slice = true; | |
| 10773 | continue; | |
| 10774 | } | |
| 10775 | ||
| 10776 | 10755 | // *[N]T to []T |
| 10777 | 10756 | // *[N]T to E![]T |
| 10778 | 10757 | if (cur_type->id == ZigTypeIdPointer && |
| ... | ... | @@ -10820,19 +10799,6 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10820 | 10799 | } |
| 10821 | 10800 | } |
| 10822 | 10801 | |
| 10823 | // [N]T to []T | |
| 10824 | if (cur_type->id == ZigTypeIdArray && is_slice(prev_type) && | |
| 10825 | (prev_type->data.structure.fields[slice_ptr_index]->type_entry->data.pointer.is_const || | |
| 10826 | cur_type->data.array.len == 0) && | |
| 10827 | types_match_const_cast_only(ira, | |
| 10828 | prev_type->data.structure.fields[slice_ptr_index]->type_entry->data.pointer.child_type, | |
| 10829 | cur_type->data.array.child_type, source_node, false).id == ConstCastResultIdOk) | |
| 10830 | { | |
| 10831 | convert_to_const_slice = false; | |
| 10832 | continue; | |
| 10833 | } | |
| 10834 | ||
| 10835 | ||
| 10836 | 10802 | // *[N]T and *[M]T |
| 10837 | 10803 | if (cur_type->id == ZigTypeIdPointer && cur_type->data.pointer.ptr_len == PtrLenSingle && |
| 10838 | 10804 | cur_type->data.pointer.child_type->id == ZigTypeIdArray && |
| ... | ... | @@ -10876,19 +10842,6 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10876 | 10842 | continue; |
| 10877 | 10843 | } |
| 10878 | 10844 | |
| 10879 | // [N]T to []T | |
| 10880 | if (prev_type->id == ZigTypeIdArray && is_slice(cur_type) && | |
| 10881 | (cur_type->data.structure.fields[slice_ptr_index]->type_entry->data.pointer.is_const || | |
| 10882 | prev_type->data.array.len == 0) && | |
| 10883 | types_match_const_cast_only(ira, | |
| 10884 | cur_type->data.structure.fields[slice_ptr_index]->type_entry->data.pointer.child_type, | |
| 10885 | prev_type->data.array.child_type, source_node, false).id == ConstCastResultIdOk) | |
| 10886 | { | |
| 10887 | prev_inst = cur_inst; | |
| 10888 | convert_to_const_slice = false; | |
| 10889 | continue; | |
| 10890 | } | |
| 10891 | ||
| 10892 | 10845 | if (prev_type->id == ZigTypeIdEnum && cur_type->id == ZigTypeIdUnion && |
| 10893 | 10846 | (cur_type->data.unionation.decl_node->data.container_decl.auto_enum || cur_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr)) |
| 10894 | 10847 | { |
| ... | ... | @@ -10924,18 +10877,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10924 | 10877 | free(errors); |
| 10925 | 10878 | |
| 10926 | 10879 | if (convert_to_const_slice) { |
| 10927 | if (prev_inst->value->type->id == ZigTypeIdArray) { | |
| 10928 | ZigType *ptr_type = get_pointer_to_type_extra( | |
| 10929 | ira->codegen, prev_inst->value->type->data.array.child_type, | |
| 10930 | true, false, PtrLenUnknown, | |
| 10931 | 0, 0, 0, false); | |
| 10932 | ZigType *slice_type = get_slice_type(ira->codegen, ptr_type); | |
| 10933 | if (err_set_type != nullptr) { | |
| 10934 | return get_error_union_type(ira->codegen, err_set_type, slice_type); | |
| 10935 | } else { | |
| 10936 | return slice_type; | |
| 10937 | } | |
| 10938 | } else if (prev_inst->value->type->id == ZigTypeIdPointer) { | |
| 10880 | if (prev_inst->value->type->id == ZigTypeIdPointer) { | |
| 10939 | 10881 | ZigType *array_type = prev_inst->value->type->data.pointer.child_type; |
| 10940 | 10882 | src_assert(array_type->id == ZigTypeIdArray, source_node); |
| 10941 | 10883 | ZigType *ptr_type = get_pointer_to_type_extra2( |
| ... | ... | @@ -12021,52 +11963,6 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi |
| 12021 | 11963 | return new_instruction; |
| 12022 | 11964 | } |
| 12023 | 11965 | |
| 12024 | static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *source_instr, | |
| 12025 | IrInstruction *array_arg, ZigType *wanted_type, ResultLoc *result_loc) | |
| 12026 | { | |
| 12027 | assert(is_slice(wanted_type)); | |
| 12028 | // In this function we honor the const-ness of wanted_type, because | |
| 12029 | // we may be casting [0]T to []const T which is perfectly valid. | |
| 12030 | ||
| 12031 | IrInstruction *array_ptr = nullptr; | |
| 12032 | IrInstruction *array; | |
| 12033 | if (array_arg->value->type->id == ZigTypeIdPointer) { | |
| 12034 | array = ir_get_deref(ira, source_instr, array_arg, nullptr); | |
| 12035 | array_ptr = array_arg; | |
| 12036 | } else { | |
| 12037 | array = array_arg; | |
| 12038 | } | |
| 12039 | ZigType *array_type = array->value->type; | |
| 12040 | assert(array_type->id == ZigTypeIdArray); | |
| 12041 | ||
| 12042 | if (instr_is_comptime(array) || array_type->data.array.len == 0) { | |
| 12043 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | |
| 12044 | init_const_slice(ira->codegen, result->value, array->value, 0, array_type->data.array.len, true); | |
| 12045 | result->value->type = wanted_type; | |
| 12046 | return result; | |
| 12047 | } | |
| 12048 | ||
| 12049 | IrInstruction *start = ir_const(ira, source_instr, ira->codegen->builtin_types.entry_usize); | |
| 12050 | init_const_usize(ira->codegen, start->value, 0); | |
| 12051 | ||
| 12052 | IrInstruction *end = ir_const(ira, source_instr, ira->codegen->builtin_types.entry_usize); | |
| 12053 | init_const_usize(ira->codegen, end->value, array_type->data.array.len); | |
| 12054 | ||
| 12055 | if (!array_ptr) array_ptr = ir_get_ref(ira, source_instr, array, true, false); | |
| 12056 | ||
| 12057 | if (result_loc == nullptr) result_loc = no_result_loc(); | |
| 12058 | IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, | |
| 12059 | true, false, true); | |
| 12060 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { | |
| 12061 | return result_loc_inst; | |
| 12062 | } | |
| 12063 | IrInstruction *result = ir_build_slice_gen(ira, source_instr, wanted_type, array_ptr, start, end, false, result_loc_inst); | |
| 12064 | result->value->data.rh_slice.id = RuntimeHintSliceIdLen; | |
| 12065 | result->value->data.rh_slice.len = array_type->data.array.len; | |
| 12066 | ||
| 12067 | return result; | |
| 12068 | } | |
| 12069 | ||
| 12070 | 11966 | static ZigType *ir_resolve_union_tag_type(IrAnalyze *ira, IrInstruction *source_instr, ZigType *union_type) { |
| 12071 | 11967 | assert(union_type->id == ZigTypeIdUnion); |
| 12072 | 11968 | |
| ... | ... | @@ -13101,44 +12997,6 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13101 | 12997 | return ir_analyze_widen_or_shorten(ira, source_instr, value, wanted_type); |
| 13102 | 12998 | } |
| 13103 | 12999 | |
| 13104 | // cast from [N]T to []const T | |
| 13105 | // TODO: once https://github.com/ziglang/zig/issues/265 lands, remove this | |
| 13106 | if (is_slice(wanted_type) && actual_type->id == ZigTypeIdArray) { | |
| 13107 | ZigType *ptr_type = wanted_type->data.structure.fields[slice_ptr_index]->type_entry; | |
| 13108 | assert(ptr_type->id == ZigTypeIdPointer); | |
| 13109 | if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) && | |
| 13110 | types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type, | |
| 13111 | source_node, false).id == ConstCastResultIdOk) | |
| 13112 | { | |
| 13113 | return ir_analyze_array_to_slice(ira, source_instr, value, wanted_type, nullptr); | |
| 13114 | } | |
| 13115 | } | |
| 13116 | ||
| 13117 | // cast from [N]T to ?[]const T | |
| 13118 | // TODO: once https://github.com/ziglang/zig/issues/265 lands, remove this | |
| 13119 | if (wanted_type->id == ZigTypeIdOptional && | |
| 13120 | is_slice(wanted_type->data.maybe.child_type) && | |
| 13121 | actual_type->id == ZigTypeIdArray) | |
| 13122 | { | |
| 13123 | ZigType *ptr_type = | |
| 13124 | wanted_type->data.maybe.child_type->data.structure.fields[slice_ptr_index]->type_entry; | |
| 13125 | assert(ptr_type->id == ZigTypeIdPointer); | |
| 13126 | if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) && | |
| 13127 | types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type, | |
| 13128 | source_node, false).id == ConstCastResultIdOk) | |
| 13129 | { | |
| 13130 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value); | |
| 13131 | if (type_is_invalid(cast1->value->type)) | |
| 13132 | return ira->codegen->invalid_instruction; | |
| 13133 | ||
| 13134 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); | |
| 13135 | if (type_is_invalid(cast2->value->type)) | |
| 13136 | return ira->codegen->invalid_instruction; | |
| 13137 | ||
| 13138 | return cast2; | |
| 13139 | } | |
| 13140 | } | |
| 13141 | ||
| 13142 | 13000 | // *[N]T to ?[]const T |
| 13143 | 13001 | if (wanted_type->id == ZigTypeIdOptional && |
| 13144 | 13002 | is_slice(wanted_type->data.maybe.child_type) && |
| ... | ... | @@ -13284,20 +13142,41 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13284 | 13142 | } |
| 13285 | 13143 | |
| 13286 | 13144 | // *@Frame(func) to anyframe->T or anyframe |
| 13145 | // *@Frame(func) to ?anyframe->T or ?anyframe | |
| 13146 | // *@Frame(func) to E!anyframe->T or E!anyframe | |
| 13287 | 13147 | if (actual_type->id == ZigTypeIdPointer && actual_type->data.pointer.ptr_len == PtrLenSingle && |
| 13288 | 13148 | !actual_type->data.pointer.is_const && |
| 13289 | actual_type->data.pointer.child_type->id == ZigTypeIdFnFrame && wanted_type->id == ZigTypeIdAnyFrame) | |
| 13149 | actual_type->data.pointer.child_type->id == ZigTypeIdFnFrame) | |
| 13290 | 13150 | { |
| 13291 | bool ok = true; | |
| 13292 | if (wanted_type->data.any_frame.result_type != nullptr) { | |
| 13293 | ZigFn *fn = actual_type->data.pointer.child_type->data.frame.fn; | |
| 13294 | ZigType *fn_return_type = fn->type_entry->data.fn.fn_type_id.return_type; | |
| 13295 | if (wanted_type->data.any_frame.result_type != fn_return_type) { | |
| 13296 | ok = false; | |
| 13151 | ZigType *anyframe_type; | |
| 13152 | if (wanted_type->id == ZigTypeIdAnyFrame) { | |
| 13153 | anyframe_type = wanted_type; | |
| 13154 | } else if (wanted_type->id == ZigTypeIdOptional && | |
| 13155 | wanted_type->data.maybe.child_type->id == ZigTypeIdAnyFrame) | |
| 13156 | { | |
| 13157 | anyframe_type = wanted_type->data.maybe.child_type; | |
| 13158 | } else if (wanted_type->id == ZigTypeIdErrorUnion && | |
| 13159 | wanted_type->data.error_union.payload_type->id == ZigTypeIdAnyFrame) | |
| 13160 | { | |
| 13161 | anyframe_type = wanted_type->data.error_union.payload_type; | |
| 13162 | } else { | |
| 13163 | anyframe_type = nullptr; | |
| 13164 | } | |
| 13165 | if (anyframe_type != nullptr) { | |
| 13166 | bool ok = true; | |
| 13167 | if (anyframe_type->data.any_frame.result_type != nullptr) { | |
| 13168 | ZigFn *fn = actual_type->data.pointer.child_type->data.frame.fn; | |
| 13169 | ZigType *fn_return_type = fn->type_entry->data.fn.fn_type_id.return_type; | |
| 13170 | if (anyframe_type->data.any_frame.result_type != fn_return_type) { | |
| 13171 | ok = false; | |
| 13172 | } | |
| 13173 | } | |
| 13174 | if (ok) { | |
| 13175 | IrInstruction *cast1 = ir_analyze_frame_ptr_to_anyframe(ira, source_instr, value, anyframe_type); | |
| 13176 | if (anyframe_type == wanted_type) | |
| 13177 | return cast1; | |
| 13178 | return ir_analyze_cast(ira, source_instr, wanted_type, cast1); | |
| 13297 | 13179 | } |
| 13298 | } | |
| 13299 | if (ok) { | |
| 13300 | return ir_analyze_frame_ptr_to_anyframe(ira, source_instr, value, wanted_type); | |
| 13301 | 13180 | } |
| 13302 | 13181 | } |
| 13303 | 13182 | |
| ... | ... | @@ -13322,30 +13201,6 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13322 | 13201 | return ir_analyze_null_to_c_pointer(ira, source_instr, value, wanted_type); |
| 13323 | 13202 | } |
| 13324 | 13203 | |
| 13325 | // cast from [N]T to E![]const T | |
| 13326 | if (wanted_type->id == ZigTypeIdErrorUnion && | |
| 13327 | is_slice(wanted_type->data.error_union.payload_type) && | |
| 13328 | actual_type->id == ZigTypeIdArray) | |
| 13329 | { | |
| 13330 | ZigType *ptr_type = | |
| 13331 | wanted_type->data.error_union.payload_type->data.structure.fields[slice_ptr_index]->type_entry; | |
| 13332 | assert(ptr_type->id == ZigTypeIdPointer); | |
| 13333 | if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) && | |
| 13334 | types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type, | |
| 13335 | source_node, false).id == ConstCastResultIdOk) | |
| 13336 | { | |
| 13337 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value); | |
| 13338 | if (type_is_invalid(cast1->value->type)) | |
| 13339 | return ira->codegen->invalid_instruction; | |
| 13340 | ||
| 13341 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); | |
| 13342 | if (type_is_invalid(cast2->value->type)) | |
| 13343 | return ira->codegen->invalid_instruction; | |
| 13344 | ||
| 13345 | return cast2; | |
| 13346 | } | |
| 13347 | } | |
| 13348 | ||
| 13349 | 13204 | // cast from E to E!T |
| 13350 | 13205 | if (wanted_type->id == ZigTypeIdErrorUnion && |
| 13351 | 13206 | actual_type->id == ZigTypeIdErrorSet) |
| ... | ... | @@ -13541,6 +13396,16 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13541 | 13396 | return ir_analyze_undefined_to_anything(ira, source_instr, value, wanted_type); |
| 13542 | 13397 | } |
| 13543 | 13398 | |
| 13399 | // T to ?E!T | |
| 13400 | if (wanted_type->id == ZigTypeIdOptional && wanted_type->data.maybe.child_type->id == ZigTypeIdErrorUnion && | |
| 13401 | actual_type->id != ZigTypeIdOptional) | |
| 13402 | { | |
| 13403 | IrInstruction *cast1 = ir_implicit_cast2(ira, source_instr, value, wanted_type->data.maybe.child_type); | |
| 13404 | if (type_is_invalid(cast1->value->type)) | |
| 13405 | return ira->codegen->invalid_instruction; | |
| 13406 | return ir_implicit_cast2(ira, source_instr, cast1, wanted_type); | |
| 13407 | } | |
| 13408 | ||
| 13544 | 13409 | ErrorMsg *parent_msg = ir_add_error_node(ira, source_instr->source_node, |
| 13545 | 13410 | buf_sprintf("expected type '%s', found '%s'", |
| 13546 | 13411 | buf_ptr(&wanted_type->name), |
| ... | ... | @@ -15283,10 +15148,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15283 | 15148 | |
| 15284 | 15149 | ZigValue *out_array_val; |
| 15285 | 15150 | size_t new_len = (op1_array_end - op1_array_index) + (op2_array_end - op2_array_index); |
| 15286 | if (op1_type->id == ZigTypeIdArray || op2_type->id == ZigTypeIdArray) { | |
| 15287 | result->value->type = get_array_type(ira->codegen, child_type, new_len, sentinel); | |
| 15288 | out_array_val = out_val; | |
| 15289 | } else if (op1_type->id == ZigTypeIdPointer || op2_type->id == ZigTypeIdPointer) { | |
| 15151 | if (op1_type->id == ZigTypeIdPointer || op2_type->id == ZigTypeIdPointer) { | |
| 15290 | 15152 | out_array_val = create_const_vals(1); |
| 15291 | 15153 | out_array_val->special = ConstValSpecialStatic; |
| 15292 | 15154 | out_array_val->type = get_array_type(ira->codegen, child_type, new_len, sentinel); |
| ... | ... | @@ -15314,6 +15176,9 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15314 | 15176 | out_val->data.x_struct.fields[slice_len_index]->type = ira->codegen->builtin_types.entry_usize; |
| 15315 | 15177 | out_val->data.x_struct.fields[slice_len_index]->special = ConstValSpecialStatic; |
| 15316 | 15178 | bigint_init_unsigned(&out_val->data.x_struct.fields[slice_len_index]->data.x_bigint, new_len); |
| 15179 | } else if (op1_type->id == ZigTypeIdArray || op2_type->id == ZigTypeIdArray) { | |
| 15180 | result->value->type = get_array_type(ira->codegen, child_type, new_len, sentinel); | |
| 15181 | out_array_val = out_val; | |
| 15317 | 15182 | } else { |
| 15318 | 15183 | result->value->type = get_pointer_to_type_extra2(ira->codegen, child_type, true, false, PtrLenUnknown, |
| 15319 | 15184 | 0, 0, 0, false, VECTOR_INDEX_NONE, nullptr, sentinel); |
| ... | ... | @@ -16142,7 +16007,8 @@ static IrInstruction *ir_resolve_no_result_loc(IrAnalyze *ira, IrInstruction *su |
| 16142 | 16007 | |
| 16143 | 16008 | // when calling this function, at the callsite must check for result type noreturn and propagate it up |
| 16144 | 16009 | static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspend_source_instr, |
| 16145 | ResultLoc *result_loc, ZigType *value_type, IrInstruction *value, bool force_runtime, bool non_null_comptime) | |
| 16010 | ResultLoc *result_loc, ZigType *value_type, IrInstruction *value, bool force_runtime, | |
| 16011 | bool non_null_comptime, bool allow_discard) | |
| 16146 | 16012 | { |
| 16147 | 16013 | Error err; |
| 16148 | 16014 | if (result_loc->resolved_loc != nullptr) { |
| ... | ... | @@ -16275,8 +16141,12 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16275 | 16141 | ira->src_implicit_return_type_list.append(value); |
| 16276 | 16142 | } |
| 16277 | 16143 | peer_parent->skipped = true; |
| 16278 | return ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, | |
| 16144 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, | |
| 16279 | 16145 | value_type, value, force_runtime || !is_comptime, true, true); |
| 16146 | if (parent_result_loc != nullptr) { | |
| 16147 | peer_parent->parent->written = true; | |
| 16148 | } | |
| 16149 | return parent_result_loc; | |
| 16280 | 16150 | } |
| 16281 | 16151 | |
| 16282 | 16152 | if (peer_parent->resolved_type == nullptr) { |
| ... | ... | @@ -16317,30 +16187,16 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16317 | 16187 | force_runtime, non_null_comptime); |
| 16318 | 16188 | } |
| 16319 | 16189 | |
| 16320 | ConstCastOnly const_cast_result = types_match_const_cast_only(ira, dest_type, value_type, | |
| 16321 | result_cast->base.source_instruction->source_node, false); | |
| 16322 | if (const_cast_result.id == ConstCastResultIdInvalid) | |
| 16323 | return ira->codegen->invalid_instruction; | |
| 16324 | if (const_cast_result.id != ConstCastResultIdOk) { | |
| 16325 | // We will not be able to provide a result location for this value. Create | |
| 16326 | // a new result location. | |
| 16327 | return ir_resolve_no_result_loc(ira, suspend_source_instr, result_loc, value_type, | |
| 16328 | force_runtime, non_null_comptime); | |
| 16329 | } | |
| 16330 | ||
| 16331 | // In this case we can pointer cast the result location. | |
| 16332 | 16190 | IrInstruction *casted_value; |
| 16333 | 16191 | if (value != nullptr) { |
| 16334 | 16192 | casted_value = ir_implicit_cast(ira, value, dest_type); |
| 16193 | if (type_is_invalid(casted_value->value->type)) | |
| 16194 | return ira->codegen->invalid_instruction; | |
| 16195 | dest_type = casted_value->value->type; | |
| 16335 | 16196 | } else { |
| 16336 | 16197 | casted_value = nullptr; |
| 16337 | 16198 | } |
| 16338 | 16199 | |
| 16339 | if (casted_value != nullptr && type_is_invalid(casted_value->value->type)) { | |
| 16340 | return casted_value; | |
| 16341 | } | |
| 16342 | ||
| 16343 | bool old_parent_result_loc_written = result_cast->parent->written; | |
| 16344 | 16200 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_cast->parent, |
| 16345 | 16201 | dest_type, casted_value, force_runtime, non_null_comptime, true); |
| 16346 | 16202 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| ... | ... | @@ -16378,26 +16234,24 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16378 | 16234 | parent_ptr_type->data.pointer.is_const, parent_ptr_type->data.pointer.is_volatile, PtrLenSingle, |
| 16379 | 16235 | parent_ptr_align, 0, 0, parent_ptr_type->data.pointer.allow_zero); |
| 16380 | 16236 | |
| 16381 | { | |
| 16382 | // we also need to check that this cast is OK. | |
| 16383 | ConstCastOnly const_cast_result = types_match_const_cast_only(ira, | |
| 16384 | parent_result_loc->value->type, ptr_type, | |
| 16385 | result_cast->base.source_instruction->source_node, false); | |
| 16386 | if (const_cast_result.id == ConstCastResultIdInvalid) | |
| 16387 | return ira->codegen->invalid_instruction; | |
| 16388 | if (const_cast_result.id != ConstCastResultIdOk) { | |
| 16389 | // We will not be able to provide a result location for this value. Create | |
| 16390 | // a new result location. | |
| 16391 | result_cast->parent->written = old_parent_result_loc_written; | |
| 16392 | return ir_resolve_no_result_loc(ira, suspend_source_instr, result_loc, value_type, | |
| 16393 | force_runtime, non_null_comptime); | |
| 16237 | ConstCastOnly const_cast_result = types_match_const_cast_only(ira, | |
| 16238 | parent_result_loc->value->type, ptr_type, | |
| 16239 | result_cast->base.source_instruction->source_node, false); | |
| 16240 | if (const_cast_result.id == ConstCastResultIdInvalid) | |
| 16241 | return ira->codegen->invalid_instruction; | |
| 16242 | if (const_cast_result.id != ConstCastResultIdOk) { | |
| 16243 | if (allow_discard) { | |
| 16244 | return parent_result_loc; | |
| 16394 | 16245 | } |
| 16246 | // We will not be able to provide a result location for this value. Create | |
| 16247 | // a new result location. | |
| 16248 | result_cast->parent->written = false; | |
| 16249 | return ir_resolve_no_result_loc(ira, suspend_source_instr, result_loc, value_type, | |
| 16250 | force_runtime, non_null_comptime); | |
| 16395 | 16251 | } |
| 16396 | 16252 | |
| 16397 | result_loc->written = true; | |
| 16398 | result_loc->resolved_loc = ir_analyze_ptr_cast(ira, suspend_source_instr, parent_result_loc, | |
| 16253 | return ir_analyze_ptr_cast(ira, suspend_source_instr, parent_result_loc, | |
| 16399 | 16254 | ptr_type, result_cast->base.source_instruction, false); |
| 16400 | return result_loc->resolved_loc; | |
| 16401 | 16255 | } |
| 16402 | 16256 | case ResultLocIdBitCast: { |
| 16403 | 16257 | ResultLocBitCast *result_bit_cast = reinterpret_cast<ResultLocBitCast *>(result_loc); |
| ... | ... | @@ -16483,7 +16337,7 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 16483 | 16337 | result_loc_pass1 = no_result_loc(); |
| 16484 | 16338 | } |
| 16485 | 16339 | IrInstruction *result_loc = ir_resolve_result_raw(ira, suspend_source_instr, result_loc_pass1, value_type, |
| 16486 | value, force_runtime, non_null_comptime); | |
| 16340 | value, force_runtime, non_null_comptime, allow_discard); | |
| 16487 | 16341 | if (result_loc == nullptr || (instr_is_unreachable(result_loc) || type_is_invalid(result_loc->value->type))) |
| 16488 | 16342 | return result_loc; |
| 16489 | 16343 | |
| ... | ... | @@ -16496,7 +16350,7 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 16496 | 16350 | ir_assert(result_loc->value->type->id == ZigTypeIdPointer, suspend_source_instr); |
| 16497 | 16351 | ZigType *actual_elem_type = result_loc->value->type->data.pointer.child_type; |
| 16498 | 16352 | if (actual_elem_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional && |
| 16499 | value_type->id != ZigTypeIdNull) | |
| 16353 | value_type->id != ZigTypeIdNull && value == nullptr) | |
| 16500 | 16354 | { |
| 16501 | 16355 | result_loc_pass1->written = false; |
| 16502 | 16356 | return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, result_loc, false, true); |
| ... | ... | @@ -16514,9 +16368,6 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 16514 | 16368 | return unwrapped_err_ptr; |
| 16515 | 16369 | } |
| 16516 | 16370 | } |
| 16517 | } else if (is_slice(actual_elem_type) && value_type->id == ZigTypeIdArray) { | |
| 16518 | // need to allow EndExpr to do the implicit cast from array to slice | |
| 16519 | result_loc_pass1->written = false; | |
| 16520 | 16371 | } |
| 16521 | 16372 | return result_loc; |
| 16522 | 16373 | } |
| ... | ... | @@ -17520,11 +17371,6 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17520 | 17371 | if (!handle_is_ptr(result_loc->value->type->data.pointer.child_type)) { |
| 17521 | 17372 | ir_reset_result(call_instruction->result_loc); |
| 17522 | 17373 | result_loc = nullptr; |
| 17523 | } else { | |
| 17524 | call_instruction->base.value.type = impl_fn_type_id->return_type; | |
| 17525 | IrInstruction *casted_value = ir_implicit_cast(ira, &call_instruction->base, result_loc->value.type->data.pointer.child_type); | |
| 17526 | if (type_is_invalid(casted_value->value.type)) | |
| 17527 | return casted_value; | |
| 17528 | 17374 | } |
| 17529 | 17375 | } |
| 17530 | 17376 | } else if (call_instruction->is_async_call_builtin) { |
| ... | ... | @@ -17687,11 +17533,6 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17687 | 17533 | if (!handle_is_ptr(result_loc->value->type->data.pointer.child_type)) { |
| 17688 | 17534 | ir_reset_result(call_instruction->result_loc); |
| 17689 | 17535 | result_loc = nullptr; |
| 17690 | } else { | |
| 17691 | call_instruction->base.value.type = return_type; | |
| 17692 | IrInstruction *casted_value = ir_implicit_cast(ira, &call_instruction->base, result_loc->value.type->data.pointer.child_type); | |
| 17693 | if (type_is_invalid(casted_value->value.type)) | |
| 17694 | return casted_value; | |
| 17695 | 17536 | } |
| 17696 | 17537 | } |
| 17697 | 17538 | } else if (call_instruction->is_async_call_builtin) { |
| ... | ... | @@ -21041,6 +20882,8 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 21041 | 20882 | { |
| 21042 | 20883 | // We're now done inferring the type. |
| 21043 | 20884 | container_type->data.structure.resolve_status = ResolveStatusUnstarted; |
| 20885 | } else if (container_type->id == ZigTypeIdVector) { | |
| 20886 | // OK | |
| 21044 | 20887 | } else { |
| 21045 | 20888 | ir_add_error_node(ira, instruction->base.source_node, |
| 21046 | 20889 | buf_sprintf("type '%s' does not support array initialization", |
| ... | ... | @@ -22434,17 +22277,23 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira, |
| 22434 | 22277 | return result; |
| 22435 | 22278 | } |
| 22436 | 22279 | |
| 22437 | static ZigValue *get_const_field(IrAnalyze *ira, ZigValue *struct_value, const char *name, size_t field_index) | |
| 22280 | static ZigValue *get_const_field(IrAnalyze *ira, AstNode *source_node, ZigValue *struct_value, | |
| 22281 | const char *name, size_t field_index) | |
| 22438 | 22282 | { |
| 22283 | Error err; | |
| 22439 | 22284 | ensure_field_index(struct_value->type, name, field_index); |
| 22440 | assert(struct_value->data.x_struct.fields[field_index]->special == ConstValSpecialStatic); | |
| 22441 | return struct_value->data.x_struct.fields[field_index]; | |
| 22285 | ZigValue *val = struct_value->data.x_struct.fields[field_index]; | |
| 22286 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, source_node, val, UndefBad))) | |
| 22287 | return nullptr; | |
| 22288 | return val; | |
| 22442 | 22289 | } |
| 22443 | 22290 | |
| 22444 | 22291 | static Error get_const_field_sentinel(IrAnalyze *ira, IrInstruction *source_instr, ZigValue *struct_value, |
| 22445 | 22292 | const char *name, size_t field_index, ZigType *elem_type, ZigValue **result) |
| 22446 | 22293 | { |
| 22447 | ZigValue *field_val = get_const_field(ira, struct_value, name, field_index); | |
| 22294 | ZigValue *field_val = get_const_field(ira, source_instr->source_node, struct_value, name, field_index); | |
| 22295 | if (field_val == nullptr) | |
| 22296 | return ErrorSemanticAnalyzeFail; | |
| 22448 | 22297 | IrInstruction *field_inst = ir_const(ira, source_instr, field_val->type); |
| 22449 | 22298 | IrInstruction *casted_field_inst = ir_implicit_cast(ira, field_inst, |
| 22450 | 22299 | get_optional_type(ira->codegen, elem_type)); |
| ... | ... | @@ -22455,23 +22304,31 @@ static Error get_const_field_sentinel(IrAnalyze *ira, IrInstruction *source_inst |
| 22455 | 22304 | return ErrorNone; |
| 22456 | 22305 | } |
| 22457 | 22306 | |
| 22458 | static bool get_const_field_bool(IrAnalyze *ira, ZigValue *struct_value, const char *name, size_t field_index) | |
| 22307 | static Error get_const_field_bool(IrAnalyze *ira, AstNode *source_node, ZigValue *struct_value, | |
| 22308 | const char *name, size_t field_index, bool *out) | |
| 22459 | 22309 | { |
| 22460 | ZigValue *value = get_const_field(ira, struct_value, name, field_index); | |
| 22310 | ZigValue *value = get_const_field(ira, source_node, struct_value, name, field_index); | |
| 22311 | if (value == nullptr) | |
| 22312 | return ErrorSemanticAnalyzeFail; | |
| 22461 | 22313 | assert(value->type == ira->codegen->builtin_types.entry_bool); |
| 22462 | return value->data.x_bool; | |
| 22314 | *out = value->data.x_bool; | |
| 22315 | return ErrorNone; | |
| 22463 | 22316 | } |
| 22464 | 22317 | |
| 22465 | static BigInt *get_const_field_lit_int(IrAnalyze *ira, ZigValue *struct_value, const char *name, size_t field_index) | |
| 22318 | static BigInt *get_const_field_lit_int(IrAnalyze *ira, AstNode *source_node, ZigValue *struct_value, const char *name, size_t field_index) | |
| 22466 | 22319 | { |
| 22467 | ZigValue *value = get_const_field(ira, struct_value, name, field_index); | |
| 22320 | ZigValue *value = get_const_field(ira, source_node, struct_value, name, field_index); | |
| 22321 | if (value == nullptr) | |
| 22322 | return nullptr; | |
| 22468 | 22323 | assert(value->type == ira->codegen->builtin_types.entry_num_lit_int); |
| 22469 | 22324 | return &value->data.x_bigint; |
| 22470 | 22325 | } |
| 22471 | 22326 | |
| 22472 | static ZigType *get_const_field_meta_type(IrAnalyze *ira, ZigValue *struct_value, const char *name, size_t field_index) | |
| 22327 | static ZigType *get_const_field_meta_type(IrAnalyze *ira, AstNode *source_node, ZigValue *struct_value, const char *name, size_t field_index) | |
| 22473 | 22328 | { |
| 22474 | ZigValue *value = get_const_field(ira, struct_value, name, field_index); | |
| 22329 | ZigValue *value = get_const_field(ira, source_node, struct_value, name, field_index); | |
| 22330 | if (value == nullptr) | |
| 22331 | return ira->codegen->invalid_instruction->value->type; | |
| 22475 | 22332 | assert(value->type == ira->codegen->builtin_types.entry_type); |
| 22476 | 22333 | return value->data.x_type; |
| 22477 | 22334 | } |
| ... | ... | @@ -22489,17 +22346,25 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi |
| 22489 | 22346 | return ira->codegen->builtin_types.entry_bool; |
| 22490 | 22347 | case ZigTypeIdUnreachable: |
| 22491 | 22348 | return ira->codegen->builtin_types.entry_unreachable; |
| 22492 | case ZigTypeIdInt: | |
| 22349 | case ZigTypeIdInt: { | |
| 22493 | 22350 | assert(payload->special == ConstValSpecialStatic); |
| 22494 | 22351 | assert(payload->type == ir_type_info_get_type(ira, "Int", nullptr)); |
| 22495 | return get_int_type(ira->codegen, | |
| 22496 | get_const_field_bool(ira, payload, "is_signed", 0), | |
| 22497 | bigint_as_u32(get_const_field_lit_int(ira, payload, "bits", 1))); | |
| 22352 | BigInt *bi = get_const_field_lit_int(ira, instruction->source_node, payload, "bits", 1); | |
| 22353 | if (bi == nullptr) | |
| 22354 | return ira->codegen->invalid_instruction->value->type; | |
| 22355 | bool is_signed; | |
| 22356 | if ((err = get_const_field_bool(ira, instruction->source_node, payload, "is_signed", 0, &is_signed))) | |
| 22357 | return ira->codegen->invalid_instruction->value->type; | |
| 22358 | return get_int_type(ira->codegen, is_signed, bigint_as_u32(bi)); | |
| 22359 | } | |
| 22498 | 22360 | case ZigTypeIdFloat: |
| 22499 | 22361 | { |
| 22500 | 22362 | assert(payload->special == ConstValSpecialStatic); |
| 22501 | 22363 | assert(payload->type == ir_type_info_get_type(ira, "Float", nullptr)); |
| 22502 | uint32_t bits = bigint_as_u32(get_const_field_lit_int(ira, payload, "bits", 0)); | |
| 22364 | BigInt *bi = get_const_field_lit_int(ira, instruction->source_node, payload, "bits", 0); | |
| 22365 | if (bi == nullptr) | |
| 22366 | return ira->codegen->invalid_instruction->value->type; | |
| 22367 | uint32_t bits = bigint_as_u32(bi); | |
| 22503 | 22368 | switch (bits) { |
| 22504 | 22369 | case 16: return ira->codegen->builtin_types.entry_f16; |
| 22505 | 22370 | case 32: return ira->codegen->builtin_types.entry_f32; |
| ... | ... | @@ -22515,27 +22380,51 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi |
| 22515 | 22380 | ZigType *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr); |
| 22516 | 22381 | assert(payload->special == ConstValSpecialStatic); |
| 22517 | 22382 | assert(payload->type == type_info_pointer_type); |
| 22518 | ZigValue *size_value = get_const_field(ira, payload, "size", 0); | |
| 22383 | ZigValue *size_value = get_const_field(ira, instruction->source_node, payload, "size", 0); | |
| 22519 | 22384 | assert(size_value->type == ir_type_info_get_type(ira, "Size", type_info_pointer_type)); |
| 22520 | 22385 | BuiltinPtrSize size_enum_index = (BuiltinPtrSize)bigint_as_u32(&size_value->data.x_enum_tag); |
| 22521 | 22386 | PtrLen ptr_len = size_enum_index_to_ptr_len(size_enum_index); |
| 22522 | ZigType *elem_type = get_const_field_meta_type(ira, payload, "child", 4); | |
| 22387 | ZigType *elem_type = get_const_field_meta_type(ira, instruction->source_node, payload, "child", 4); | |
| 22388 | if (type_is_invalid(elem_type)) | |
| 22389 | return ira->codegen->invalid_instruction->value->type; | |
| 22523 | 22390 | ZigValue *sentinel; |
| 22524 | 22391 | if ((err = get_const_field_sentinel(ira, instruction, payload, "sentinel", 6, |
| 22525 | 22392 | elem_type, &sentinel))) |
| 22526 | 22393 | { |
| 22527 | return nullptr; | |
| 22394 | return ira->codegen->invalid_instruction->value->type; | |
| 22395 | } | |
| 22396 | BigInt *bi = get_const_field_lit_int(ira, instruction->source_node, payload, "alignment", 3); | |
| 22397 | if (bi == nullptr) | |
| 22398 | return ira->codegen->invalid_instruction->value->type; | |
| 22399 | ||
| 22400 | bool is_const; | |
| 22401 | if ((err = get_const_field_bool(ira, instruction->source_node, payload, "is_const", 1, &is_const))) | |
| 22402 | return ira->codegen->invalid_instruction->value->type; | |
| 22403 | ||
| 22404 | bool is_volatile; | |
| 22405 | if ((err = get_const_field_bool(ira, instruction->source_node, payload, "is_volatile", 2, | |
| 22406 | &is_volatile))) | |
| 22407 | { | |
| 22408 | return ira->codegen->invalid_instruction->value->type; | |
| 22409 | } | |
| 22410 | ||
| 22411 | bool is_allowzero; | |
| 22412 | if ((err = get_const_field_bool(ira, instruction->source_node, payload, "is_allowzero", 5, | |
| 22413 | &is_allowzero))) | |
| 22414 | { | |
| 22415 | return ira->codegen->invalid_instruction->value->type; | |
| 22528 | 22416 | } |
| 22529 | 22417 | |
| 22418 | ||
| 22530 | 22419 | ZigType *ptr_type = get_pointer_to_type_extra2(ira->codegen, |
| 22531 | 22420 | elem_type, |
| 22532 | get_const_field_bool(ira, payload, "is_const", 1), | |
| 22533 | get_const_field_bool(ira, payload, "is_volatile", 2), | |
| 22421 | is_const, | |
| 22422 | is_volatile, | |
| 22534 | 22423 | ptr_len, |
| 22535 | bigint_as_u32(get_const_field_lit_int(ira, payload, "alignment", 3)), | |
| 22424 | bigint_as_u32(bi), | |
| 22536 | 22425 | 0, // bit_offset_in_host |
| 22537 | 22426 | 0, // host_int_bytes |
| 22538 | get_const_field_bool(ira, payload, "is_allowzero", 5), | |
| 22427 | is_allowzero, | |
| 22539 | 22428 | VECTOR_INDEX_NONE, nullptr, sentinel); |
| 22540 | 22429 | if (size_enum_index != 2) |
| 22541 | 22430 | return ptr_type; |
| ... | ... | @@ -22544,17 +22433,19 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi |
| 22544 | 22433 | case ZigTypeIdArray: { |
| 22545 | 22434 | assert(payload->special == ConstValSpecialStatic); |
| 22546 | 22435 | assert(payload->type == ir_type_info_get_type(ira, "Array", nullptr)); |
| 22547 | ZigType *elem_type = get_const_field_meta_type(ira, payload, "child", 1); | |
| 22436 | ZigType *elem_type = get_const_field_meta_type(ira, instruction->source_node, payload, "child", 1); | |
| 22437 | if (type_is_invalid(elem_type)) | |
| 22438 | return ira->codegen->invalid_instruction->value->type; | |
| 22548 | 22439 | ZigValue *sentinel; |
| 22549 | 22440 | if ((err = get_const_field_sentinel(ira, instruction, payload, "sentinel", 2, |
| 22550 | 22441 | elem_type, &sentinel))) |
| 22551 | 22442 | { |
| 22552 | return nullptr; | |
| 22443 | return ira->codegen->invalid_instruction->value->type; | |
| 22553 | 22444 | } |
| 22554 | return get_array_type(ira->codegen, | |
| 22555 | elem_type, | |
| 22556 | bigint_as_u64(get_const_field_lit_int(ira, payload, "len", 0)), | |
| 22557 | sentinel); | |
| 22445 | BigInt *bi = get_const_field_lit_int(ira, instruction->source_node, payload, "len", 0); | |
| 22446 | if (bi == nullptr) | |
| 22447 | return ira->codegen->invalid_instruction->value->type; | |
| 22448 | return get_array_type(ira->codegen, elem_type, bigint_as_u64(bi), sentinel); | |
| 22558 | 22449 | } |
| 22559 | 22450 | case ZigTypeIdComptimeFloat: |
| 22560 | 22451 | return ira->codegen->builtin_types.entry_num_lit_float; |
| ... | ... | @@ -22575,7 +22466,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi |
| 22575 | 22466 | case ZigTypeIdEnumLiteral: |
| 22576 | 22467 | ir_add_error(ira, instruction, buf_sprintf( |
| 22577 | 22468 | "TODO implement @Type for 'TypeInfo.%s': see https://github.com/ziglang/zig/issues/2907", type_id_name(tagTypeId))); |
| 22578 | return nullptr; | |
| 22469 | return ira->codegen->invalid_instruction->value->type; | |
| 22579 | 22470 | case ZigTypeIdUnion: |
| 22580 | 22471 | case ZigTypeIdFn: |
| 22581 | 22472 | case ZigTypeIdBoundFn: |
| ... | ... | @@ -22583,7 +22474,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi |
| 22583 | 22474 | case ZigTypeIdStruct: |
| 22584 | 22475 | ir_add_error(ira, instruction, buf_sprintf( |
| 22585 | 22476 | "@Type not availble for 'TypeInfo.%s'", type_id_name(tagTypeId))); |
| 22586 | return nullptr; | |
| 22477 | return ira->codegen->invalid_instruction->value->type; | |
| 22587 | 22478 | } |
| 22588 | 22479 | zig_unreachable(); |
| 22589 | 22480 | } |
| ... | ... | @@ -22602,7 +22493,7 @@ static IrInstruction *ir_analyze_instruction_type(IrAnalyze *ira, IrInstructionT |
| 22602 | 22493 | return ira->codegen->invalid_instruction; |
| 22603 | 22494 | ZigTypeId typeId = type_id_at_index(bigint_as_usize(&type_info_value->data.x_union.tag)); |
| 22604 | 22495 | ZigType *type = type_info_to_type(ira, type_info_ir, typeId, type_info_value->data.x_union.payload); |
| 22605 | if (!type) | |
| 22496 | if (type_is_invalid(type)) | |
| 22606 | 22497 | return ira->codegen->invalid_instruction; |
| 22607 | 22498 | return ir_const_type(ira, &instruction->base, type); |
| 22608 | 22499 | } |
| ... | ... | @@ -28332,3 +28223,18 @@ Error ir_resolve_lazy(CodeGen *codegen, AstNode *source_node, ZigValue *val) { |
| 28332 | 28223 | } |
| 28333 | 28224 | return ErrorNone; |
| 28334 | 28225 | } |
| 28226 | ||
| 28227 | void IrInstruction::dump() { | |
| 28228 | IrInstruction *inst = this; | |
| 28229 | if (inst->source_node != nullptr) { | |
| 28230 | inst->source_node->src(); | |
| 28231 | } else { | |
| 28232 | fprintf(stderr, "(null source node)\n"); | |
| 28233 | } | |
| 28234 | IrPass pass = (inst->child == nullptr) ? IrPassGen : IrPassSrc; | |
| 28235 | ir_print_instruction(inst->scope->codegen, stderr, inst, 0, pass); | |
| 28236 | if (pass == IrPassSrc) { | |
| 28237 | fprintf(stderr, "-> "); | |
| 28238 | ir_print_instruction(inst->scope->codegen, stderr, inst->child, 0, IrPassGen); | |
| 28239 | } | |
| 28240 | } |
test/compare_output.zig+2-2| ... | ... | @@ -465,7 +465,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 465 | 465 | \\ |
| 466 | 466 | ); |
| 467 | 467 | |
| 468 | tc.setCommandLineArgs([_][]const u8{ | |
| 468 | tc.setCommandLineArgs(&[_][]const u8{ | |
| 469 | 469 | "first arg", |
| 470 | 470 | "'a' 'b' \\", |
| 471 | 471 | "bare", |
| ... | ... | @@ -506,7 +506,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 506 | 506 | \\ |
| 507 | 507 | ); |
| 508 | 508 | |
| 509 | tc.setCommandLineArgs([_][]const u8{ | |
| 509 | tc.setCommandLineArgs(&[_][]const u8{ | |
| 510 | 510 | "first arg", |
| 511 | 511 | "'a' 'b' \\", |
| 512 | 512 | "bare", |
test/stage1/behavior/array.zig+22-22| ... | ... | @@ -20,7 +20,7 @@ test "arrays" { |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | expect(accumulator == 15); |
| 23 | expect(getArrayLen(array) == 5); | |
| 23 | expect(getArrayLen(&array) == 5); | |
| 24 | 24 | } |
| 25 | 25 | fn getArrayLen(a: []const u32) usize { |
| 26 | 26 | return a.len; |
| ... | ... | @@ -182,29 +182,29 @@ fn plusOne(x: u32) u32 { |
| 182 | 182 | |
| 183 | 183 | test "runtime initialize array elem and then implicit cast to slice" { |
| 184 | 184 | var two: i32 = 2; |
| 185 | const x: []const i32 = [_]i32{two}; | |
| 185 | const x: []const i32 = &[_]i32{two}; | |
| 186 | 186 | expect(x[0] == 2); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | test "array literal as argument to function" { |
| 190 | 190 | const S = struct { |
| 191 | 191 | fn entry(two: i32) void { |
| 192 | foo([_]i32{ | |
| 192 | foo(&[_]i32{ | |
| 193 | 193 | 1, |
| 194 | 194 | 2, |
| 195 | 195 | 3, |
| 196 | 196 | }); |
| 197 | foo([_]i32{ | |
| 197 | foo(&[_]i32{ | |
| 198 | 198 | 1, |
| 199 | 199 | two, |
| 200 | 200 | 3, |
| 201 | 201 | }); |
| 202 | foo2(true, [_]i32{ | |
| 202 | foo2(true, &[_]i32{ | |
| 203 | 203 | 1, |
| 204 | 204 | 2, |
| 205 | 205 | 3, |
| 206 | 206 | }); |
| 207 | foo2(true, [_]i32{ | |
| 207 | foo2(true, &[_]i32{ | |
| 208 | 208 | 1, |
| 209 | 209 | two, |
| 210 | 210 | 3, |
| ... | ... | @@ -230,17 +230,17 @@ test "double nested array to const slice cast in array literal" { |
| 230 | 230 | const S = struct { |
| 231 | 231 | fn entry(two: i32) void { |
| 232 | 232 | const cases = [_][]const []const i32{ |
| 233 | [_][]const i32{[_]i32{1}}, | |
| 234 | [_][]const i32{[_]i32{ 2, 3 }}, | |
| 235 | [_][]const i32{ | |
| 236 | [_]i32{4}, | |
| 237 | [_]i32{ 5, 6, 7 }, | |
| 233 | &[_][]const i32{&[_]i32{1}}, | |
| 234 | &[_][]const i32{&[_]i32{ 2, 3 }}, | |
| 235 | &[_][]const i32{ | |
| 236 | &[_]i32{4}, | |
| 237 | &[_]i32{ 5, 6, 7 }, | |
| 238 | 238 | }, |
| 239 | 239 | }; |
| 240 | check(cases); | |
| 240 | check(&cases); | |
| 241 | 241 | |
| 242 | 242 | const cases2 = [_][]const i32{ |
| 243 | [_]i32{1}, | |
| 243 | &[_]i32{1}, | |
| 244 | 244 | &[_]i32{ two, 3 }, |
| 245 | 245 | }; |
| 246 | 246 | expect(cases2.len == 2); |
| ... | ... | @@ -251,14 +251,14 @@ test "double nested array to const slice cast in array literal" { |
| 251 | 251 | expect(cases2[1][1] == 3); |
| 252 | 252 | |
| 253 | 253 | const cases3 = [_][]const []const i32{ |
| 254 | [_][]const i32{[_]i32{1}}, | |
| 254 | &[_][]const i32{&[_]i32{1}}, | |
| 255 | 255 | &[_][]const i32{&[_]i32{ two, 3 }}, |
| 256 | [_][]const i32{ | |
| 257 | [_]i32{4}, | |
| 258 | [_]i32{ 5, 6, 7 }, | |
| 256 | &[_][]const i32{ | |
| 257 | &[_]i32{4}, | |
| 258 | &[_]i32{ 5, 6, 7 }, | |
| 259 | 259 | }, |
| 260 | 260 | }; |
| 261 | check(cases3); | |
| 261 | check(&cases3); | |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | fn check(cases: []const []const []const i32) void { |
| ... | ... | @@ -316,7 +316,7 @@ test "implicit cast zero sized array ptr to slice" { |
| 316 | 316 | test "anonymous list literal syntax" { |
| 317 | 317 | const S = struct { |
| 318 | 318 | fn doTheTest() void { |
| 319 | var array: [4]u8 = .{1, 2, 3, 4}; | |
| 319 | var array: [4]u8 = .{ 1, 2, 3, 4 }; | |
| 320 | 320 | expect(array[0] == 1); |
| 321 | 321 | expect(array[1] == 2); |
| 322 | 322 | expect(array[2] == 3); |
| ... | ... | @@ -335,8 +335,8 @@ test "anonymous literal in array" { |
| 335 | 335 | }; |
| 336 | 336 | fn doTheTest() void { |
| 337 | 337 | var array: [2]Foo = .{ |
| 338 | .{.a = 3}, | |
| 339 | .{.b = 3}, | |
| 338 | .{ .a = 3 }, | |
| 339 | .{ .b = 3 }, | |
| 340 | 340 | }; |
| 341 | 341 | expect(array[0].a == 3); |
| 342 | 342 | expect(array[0].b == 4); |
| ... | ... | @@ -351,7 +351,7 @@ test "anonymous literal in array" { |
| 351 | 351 | test "access the null element of a null terminated array" { |
| 352 | 352 | const S = struct { |
| 353 | 353 | fn doTheTest() void { |
| 354 | var array: [4:0]u8 = .{'a', 'o', 'e', 'u'}; | |
| 354 | var array: [4:0]u8 = .{ 'a', 'o', 'e', 'u' }; | |
| 355 | 355 | comptime expect(array[4] == 0); |
| 356 | 356 | var len: usize = 4; |
| 357 | 357 | expect(array[len] == 0); |
test/stage1/behavior/async_fn.zig+6-6| ... | ... | @@ -143,7 +143,7 @@ test "coroutine suspend, resume" { |
| 143 | 143 | resume frame; |
| 144 | 144 | seq('h'); |
| 145 | 145 | |
| 146 | expect(std.mem.eql(u8, points, "abcdefgh")); | |
| 146 | expect(std.mem.eql(u8, &points, "abcdefgh")); | |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | fn amain() void { |
| ... | ... | @@ -206,7 +206,7 @@ test "coroutine await" { |
| 206 | 206 | resume await_a_promise; |
| 207 | 207 | await_seq('i'); |
| 208 | 208 | expect(await_final_result == 1234); |
| 209 | expect(std.mem.eql(u8, await_points, "abcdefghi")); | |
| 209 | expect(std.mem.eql(u8, &await_points, "abcdefghi")); | |
| 210 | 210 | } |
| 211 | 211 | async fn await_amain() void { |
| 212 | 212 | await_seq('b'); |
| ... | ... | @@ -240,7 +240,7 @@ test "coroutine await early return" { |
| 240 | 240 | var p = async early_amain(); |
| 241 | 241 | early_seq('f'); |
| 242 | 242 | expect(early_final_result == 1234); |
| 243 | expect(std.mem.eql(u8, early_points, "abcdef")); | |
| 243 | expect(std.mem.eql(u8, &early_points, "abcdef")); | |
| 244 | 244 | } |
| 245 | 245 | async fn early_amain() void { |
| 246 | 246 | early_seq('b'); |
| ... | ... | @@ -1166,7 +1166,7 @@ test "suspend in for loop" { |
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | fn atest() void { |
| 1169 | expect(func([_]u8{ 1, 2, 3 }) == 6); | |
| 1169 | expect(func(&[_]u8{ 1, 2, 3 }) == 6); | |
| 1170 | 1170 | } |
| 1171 | 1171 | fn func(stuff: []const u8) u32 { |
| 1172 | 1172 | global_frame = @frame(); |
| ... | ... | @@ -1211,7 +1211,7 @@ test "spill target expr in a for loop" { |
| 1211 | 1211 | |
| 1212 | 1212 | fn doTheTest() void { |
| 1213 | 1213 | var foo = Foo{ |
| 1214 | .slice = [_]i32{ 1, 2 }, | |
| 1214 | .slice = &[_]i32{ 1, 2 }, | |
| 1215 | 1215 | }; |
| 1216 | 1216 | expect(atest(&foo) == 3); |
| 1217 | 1217 | } |
| ... | ... | @@ -1242,7 +1242,7 @@ test "spill target expr in a for loop, with a var decl in the loop body" { |
| 1242 | 1242 | |
| 1243 | 1243 | fn doTheTest() void { |
| 1244 | 1244 | var foo = Foo{ |
| 1245 | .slice = [_]i32{ 1, 2 }, | |
| 1245 | .slice = &[_]i32{ 1, 2 }, | |
| 1246 | 1246 | }; |
| 1247 | 1247 | expect(atest(&foo) == 3); |
| 1248 | 1248 | } |
test/stage1/behavior/await_struct.zig+1-1| ... | ... | @@ -16,7 +16,7 @@ test "coroutine await struct" { |
| 16 | 16 | resume await_a_promise; |
| 17 | 17 | await_seq('i'); |
| 18 | 18 | expect(await_final_result.x == 1234); |
| 19 | expect(std.mem.eql(u8, await_points, "abcdefghi")); | |
| 19 | expect(std.mem.eql(u8, &await_points, "abcdefghi")); | |
| 20 | 20 | } |
| 21 | 21 | async fn await_amain() void { |
| 22 | 22 | await_seq('b'); |
test/stage1/behavior/bugs/1607.zig+2-2| ... | ... | @@ -10,6 +10,6 @@ fn checkAddress(s: []const u8) void { |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | test "slices pointing at the same address as global array." { |
| 13 | checkAddress(a); | |
| 14 | comptime checkAddress(a); | |
| 13 | checkAddress(&a); | |
| 14 | comptime checkAddress(&a); | |
| 15 | 15 | } |
test/stage1/behavior/bugs/1914.zig+2-2| ... | ... | @@ -7,7 +7,7 @@ const B = struct { |
| 7 | 7 | a_pointer: *const A, |
| 8 | 8 | }; |
| 9 | 9 | |
| 10 | const b_list: []B = [_]B{}; | |
| 10 | const b_list: []B = &[_]B{}; | |
| 11 | 11 | const a = A{ .b_list_pointer = &b_list }; |
| 12 | 12 | |
| 13 | 13 | test "segfault bug" { |
| ... | ... | @@ -24,7 +24,7 @@ pub const B2 = struct { |
| 24 | 24 | pointer_array: []*A2, |
| 25 | 25 | }; |
| 26 | 26 | |
| 27 | var b_value = B2{ .pointer_array = [_]*A2{} }; | |
| 27 | var b_value = B2{ .pointer_array = &[_]*A2{} }; | |
| 28 | 28 | |
| 29 | 29 | test "basic stuff" { |
| 30 | 30 | std.debug.assert(&b_value == &b_value); |
test/stage1/behavior/cast.zig+36-13| ... | ... | @@ -150,7 +150,7 @@ test "peer type resolution: [0]u8 and []const u8" { |
| 150 | 150 | } |
| 151 | 151 | fn peerTypeEmptyArrayAndSlice(a: bool, slice: []const u8) []const u8 { |
| 152 | 152 | if (a) { |
| 153 | return [_]u8{}; | |
| 153 | return &[_]u8{}; | |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | return slice[0..1]; |
| ... | ... | @@ -175,7 +175,7 @@ fn testCastZeroArrayToErrSliceMut() void { |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | fn gimmeErrOrSlice() anyerror![]u8 { |
| 178 | return [_]u8{}; | |
| 178 | return &[_]u8{}; | |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | test "peer type resolution: [0]u8, []const u8, and anyerror![]u8" { |
| ... | ... | @@ -200,7 +200,7 @@ test "peer type resolution: [0]u8, []const u8, and anyerror![]u8" { |
| 200 | 200 | } |
| 201 | 201 | fn peerTypeEmptyArrayAndSliceAndError(a: bool, slice: []u8) anyerror![]u8 { |
| 202 | 202 | if (a) { |
| 203 | return [_]u8{}; | |
| 203 | return &[_]u8{}; | |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | return slice[0..1]; |
| ... | ... | @@ -457,7 +457,7 @@ fn incrementVoidPtrValue(value: ?*c_void) void { |
| 457 | 457 | test "implicit cast from [*]T to ?*c_void" { |
| 458 | 458 | var a = [_]u8{ 3, 2, 1 }; |
| 459 | 459 | incrementVoidPtrArray(a[0..].ptr, 3); |
| 460 | expect(std.mem.eql(u8, a, [_]u8{ 4, 3, 2 })); | |
| 460 | expect(std.mem.eql(u8, &a, &[_]u8{ 4, 3, 2 })); | |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | fn incrementVoidPtrArray(array: ?*c_void, len: usize) void { |
| ... | ... | @@ -606,7 +606,12 @@ test "*const [N]null u8 to ?[]const u8" { |
| 606 | 606 | |
| 607 | 607 | test "peer resolution of string literals" { |
| 608 | 608 | const S = struct { |
| 609 | const E = extern enum { a, b, c, d}; | |
| 609 | const E = extern enum { | |
| 610 | a, | |
| 611 | b, | |
| 612 | c, | |
| 613 | d, | |
| 614 | }; | |
| 610 | 615 | |
| 611 | 616 | fn doTheTest(e: E) void { |
| 612 | 617 | const cmd = switch (e) { |
| ... | ... | @@ -627,15 +632,15 @@ test "type coercion related to sentinel-termination" { |
| 627 | 632 | fn doTheTest() void { |
| 628 | 633 | // [:x]T to []T |
| 629 | 634 | { |
| 630 | var array = [4:0]i32{1,2,3,4}; | |
| 635 | var array = [4:0]i32{ 1, 2, 3, 4 }; | |
| 631 | 636 | var slice: [:0]i32 = &array; |
| 632 | 637 | var dest: []i32 = slice; |
| 633 | expect(mem.eql(i32, dest, &[_]i32{1,2,3,4})); | |
| 638 | expect(mem.eql(i32, dest, &[_]i32{ 1, 2, 3, 4 })); | |
| 634 | 639 | } |
| 635 | 640 | |
| 636 | 641 | // [*:x]T to [*]T |
| 637 | 642 | { |
| 638 | var array = [4:99]i32{1,2,3,4}; | |
| 643 | var array = [4:99]i32{ 1, 2, 3, 4 }; | |
| 639 | 644 | var dest: [*]i32 = &array; |
| 640 | 645 | expect(dest[0] == 1); |
| 641 | 646 | expect(dest[1] == 2); |
| ... | ... | @@ -646,21 +651,21 @@ test "type coercion related to sentinel-termination" { |
| 646 | 651 | |
| 647 | 652 | // [N:x]T to [N]T |
| 648 | 653 | { |
| 649 | var array = [4:0]i32{1,2,3,4}; | |
| 654 | var array = [4:0]i32{ 1, 2, 3, 4 }; | |
| 650 | 655 | var dest: [4]i32 = array; |
| 651 | expect(mem.eql(i32, dest, &[_]i32{1,2,3,4})); | |
| 656 | expect(mem.eql(i32, &dest, &[_]i32{ 1, 2, 3, 4 })); | |
| 652 | 657 | } |
| 653 | 658 | |
| 654 | 659 | // *[N:x]T to *[N]T |
| 655 | 660 | { |
| 656 | var array = [4:0]i32{1,2,3,4}; | |
| 661 | var array = [4:0]i32{ 1, 2, 3, 4 }; | |
| 657 | 662 | var dest: *[4]i32 = &array; |
| 658 | expect(mem.eql(i32, dest, &[_]i32{1,2,3,4})); | |
| 663 | expect(mem.eql(i32, dest, &[_]i32{ 1, 2, 3, 4 })); | |
| 659 | 664 | } |
| 660 | 665 | |
| 661 | 666 | // [:x]T to [*:x]T |
| 662 | 667 | { |
| 663 | var array = [4:0]i32{1,2,3,4}; | |
| 668 | var array = [4:0]i32{ 1, 2, 3, 4 }; | |
| 664 | 669 | var slice: [:0]i32 = &array; |
| 665 | 670 | var dest: [*:0]i32 = slice; |
| 666 | 671 | expect(dest[0] == 1); |
| ... | ... | @@ -674,3 +679,21 @@ test "type coercion related to sentinel-termination" { |
| 674 | 679 | S.doTheTest(); |
| 675 | 680 | comptime S.doTheTest(); |
| 676 | 681 | } |
| 682 | ||
| 683 | test "cast i8 fn call peers to i32 result" { | |
| 684 | const S = struct { | |
| 685 | fn doTheTest() void { | |
| 686 | var cond = true; | |
| 687 | const value: i32 = if (cond) smallBoi() else bigBoi(); | |
| 688 | expect(value == 123); | |
| 689 | } | |
| 690 | fn smallBoi() i8 { | |
| 691 | return 123; | |
| 692 | } | |
| 693 | fn bigBoi() i16 { | |
| 694 | return 1234; | |
| 695 | } | |
| 696 | }; | |
| 697 | S.doTheTest(); | |
| 698 | comptime S.doTheTest(); | |
| 699 | } |
test/stage1/behavior/eval.zig+3-3| ... | ... | @@ -717,7 +717,7 @@ test "@bytesToslice on a packed struct" { |
| 717 | 717 | }; |
| 718 | 718 | |
| 719 | 719 | var b = [1]u8{9}; |
| 720 | var f = @bytesToSlice(F, b); | |
| 720 | var f = @bytesToSlice(F, &b); | |
| 721 | 721 | expect(f[0].a == 9); |
| 722 | 722 | } |
| 723 | 723 | |
| ... | ... | @@ -774,12 +774,12 @@ test "*align(1) u16 is the same as *align(1:0:2) u16" { |
| 774 | 774 | |
| 775 | 775 | test "array concatenation forces comptime" { |
| 776 | 776 | var a = oneItem(3) ++ oneItem(4); |
| 777 | expect(std.mem.eql(i32, a, [_]i32{ 3, 4 })); | |
| 777 | expect(std.mem.eql(i32, &a, &[_]i32{ 3, 4 })); | |
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | test "array multiplication forces comptime" { |
| 781 | 781 | var a = oneItem(3) ** scalar(2); |
| 782 | expect(std.mem.eql(i32, a, [_]i32{ 3, 3 })); | |
| 782 | expect(std.mem.eql(i32, &a, &[_]i32{ 3, 3 })); | |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | fn oneItem(x: i32) [1]i32 { |
test/stage1/behavior/for.zig+5-5| ... | ... | @@ -26,7 +26,7 @@ test "for loop with pointer elem var" { |
| 26 | 26 | var target: [source.len]u8 = undefined; |
| 27 | 27 | mem.copy(u8, target[0..], source); |
| 28 | 28 | mangleString(target[0..]); |
| 29 | expect(mem.eql(u8, target, "bcdefgh")); | |
| 29 | expect(mem.eql(u8, &target, "bcdefgh")); | |
| 30 | 30 | |
| 31 | 31 | for (source) |*c, i| |
| 32 | 32 | expect(@typeOf(c) == *const u8); |
| ... | ... | @@ -64,7 +64,7 @@ test "basic for loop" { |
| 64 | 64 | buffer[buf_index] = @intCast(u8, index); |
| 65 | 65 | buf_index += 1; |
| 66 | 66 | } |
| 67 | const unknown_size: []const u8 = array; | |
| 67 | const unknown_size: []const u8 = &array; | |
| 68 | 68 | for (unknown_size) |item| { |
| 69 | 69 | buffer[buf_index] = item; |
| 70 | 70 | buf_index += 1; |
| ... | ... | @@ -74,7 +74,7 @@ test "basic for loop" { |
| 74 | 74 | buf_index += 1; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | expect(mem.eql(u8, buffer[0..buf_index], expected_result)); | |
| 77 | expect(mem.eql(u8, buffer[0..buf_index], &expected_result)); | |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | test "break from outer for loop" { |
| ... | ... | @@ -139,6 +139,6 @@ test "for with null and T peer types and inferred result location type" { |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | }; |
| 142 | S.doTheTest([_]u8{ 1, 2 }); | |
| 143 | comptime S.doTheTest([_]u8{ 1, 2 }); | |
| 142 | S.doTheTest(&[_]u8{ 1, 2 }); | |
| 143 | comptime S.doTheTest(&[_]u8{ 1, 2 }); | |
| 144 | 144 | } |
test/stage1/behavior/generics.zig+2-2| ... | ... | @@ -120,8 +120,8 @@ fn aGenericFn(comptime T: type, comptime a: T, b: T) T { |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | test "generic fn with implicit cast" { |
| 123 | expect(getFirstByte(u8, [_]u8{13}) == 13); | |
| 124 | expect(getFirstByte(u16, [_]u16{ | |
| 123 | expect(getFirstByte(u8, &[_]u8{13}) == 13); | |
| 124 | expect(getFirstByte(u16, &[_]u16{ | |
| 125 | 125 | 0, |
| 126 | 126 | 13, |
| 127 | 127 | }) == 0); |
test/stage1/behavior/misc.zig+3-3| ... | ... | @@ -241,7 +241,7 @@ fn memFree(comptime T: type, memory: []T) void {} |
| 241 | 241 | |
| 242 | 242 | test "cast undefined" { |
| 243 | 243 | const array: [100]u8 = undefined; |
| 244 | const slice = @as([]const u8, array); | |
| 244 | const slice = @as([]const u8, &array); | |
| 245 | 245 | testCastUndefined(slice); |
| 246 | 246 | } |
| 247 | 247 | fn testCastUndefined(x: []const u8) void {} |
| ... | ... | @@ -614,7 +614,7 @@ test "slicing zero length array" { |
| 614 | 614 | expect(s1.len == 0); |
| 615 | 615 | expect(s2.len == 0); |
| 616 | 616 | expect(mem.eql(u8, s1, "")); |
| 617 | expect(mem.eql(u32, s2, [_]u32{})); | |
| 617 | expect(mem.eql(u32, s2, &[_]u32{})); | |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | const addr1 = @ptrCast(*const u8, emptyFn); |
| ... | ... | @@ -710,7 +710,7 @@ test "result location zero sized array inside struct field implicit cast to slic |
| 710 | 710 | const E = struct { |
| 711 | 711 | entries: []u32, |
| 712 | 712 | }; |
| 713 | var foo = E{ .entries = [_]u32{} }; | |
| 713 | var foo = E{ .entries = &[_]u32{} }; | |
| 714 | 714 | expect(foo.entries.len == 0); |
| 715 | 715 | } |
| 716 | 716 |
test/stage1/behavior/ptrcast.zig+1-1| ... | ... | @@ -37,7 +37,7 @@ fn testReinterpretBytesAsExternStruct() void { |
| 37 | 37 | |
| 38 | 38 | test "reinterpret struct field at comptime" { |
| 39 | 39 | const numLittle = comptime Bytes.init(0x12345678); |
| 40 | expect(std.mem.eql(u8, [_]u8{ 0x78, 0x56, 0x34, 0x12 }, numLittle.bytes)); | |
| 40 | expect(std.mem.eql(u8, &[_]u8{ 0x78, 0x56, 0x34, 0x12 }, &numLittle.bytes)); | |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | const Bytes = struct { |
test/stage1/behavior/shuffle.zig+7-7| ... | ... | @@ -9,28 +9,28 @@ test "@shuffle" { |
| 9 | 9 | var x: @Vector(4, i32) = [4]i32{ 1, 2147483647, 3, 4 }; |
| 10 | 10 | const mask: @Vector(4, i32) = [4]i32{ 0, ~@as(i32, 2), 3, ~@as(i32, 3) }; |
| 11 | 11 | var res = @shuffle(i32, v, x, mask); |
| 12 | expect(mem.eql(i32, @as([4]i32,res), [4]i32{ 2147483647, 3, 40, 4 })); | |
| 12 | expect(mem.eql(i32, &@as([4]i32, res), &[4]i32{ 2147483647, 3, 40, 4 })); | |
| 13 | 13 | |
| 14 | 14 | // Implicit cast from array (of mask) |
| 15 | 15 | res = @shuffle(i32, v, x, [4]i32{ 0, ~@as(i32, 2), 3, ~@as(i32, 3) }); |
| 16 | expect(mem.eql(i32, @as([4]i32,res), [4]i32{ 2147483647, 3, 40, 4 })); | |
| 16 | expect(mem.eql(i32, &@as([4]i32, res), &[4]i32{ 2147483647, 3, 40, 4 })); | |
| 17 | 17 | |
| 18 | 18 | // Undefined |
| 19 | 19 | const mask2: @Vector(4, i32) = [4]i32{ 3, 1, 2, 0 }; |
| 20 | 20 | res = @shuffle(i32, v, undefined, mask2); |
| 21 | expect(mem.eql(i32, @as([4]i32,res), [4]i32{ 40, -2, 30, 2147483647 })); | |
| 21 | expect(mem.eql(i32, &@as([4]i32, res), &[4]i32{ 40, -2, 30, 2147483647 })); | |
| 22 | 22 | |
| 23 | 23 | // Upcasting of b |
| 24 | 24 | var v2: @Vector(2, i32) = [2]i32{ 2147483647, undefined }; |
| 25 | 25 | const mask3: @Vector(4, i32) = [4]i32{ ~@as(i32, 0), 2, ~@as(i32, 0), 3 }; |
| 26 | 26 | res = @shuffle(i32, x, v2, mask3); |
| 27 | expect(mem.eql(i32, @as([4]i32,res), [4]i32{ 2147483647, 3, 2147483647, 4 })); | |
| 27 | expect(mem.eql(i32, &@as([4]i32, res), &[4]i32{ 2147483647, 3, 2147483647, 4 })); | |
| 28 | 28 | |
| 29 | 29 | // Upcasting of a |
| 30 | 30 | var v3: @Vector(2, i32) = [2]i32{ 2147483647, -2 }; |
| 31 | 31 | const mask4: @Vector(4, i32) = [4]i32{ 0, ~@as(i32, 2), 1, ~@as(i32, 3) }; |
| 32 | 32 | res = @shuffle(i32, v3, x, mask4); |
| 33 | expect(mem.eql(i32, @as([4]i32,res), [4]i32{ 2147483647, 3, -2, 4 })); | |
| 33 | expect(mem.eql(i32, &@as([4]i32, res), &[4]i32{ 2147483647, 3, -2, 4 })); | |
| 34 | 34 | |
| 35 | 35 | // bool |
| 36 | 36 | // Disabled because of #3317 |
| ... | ... | @@ -39,7 +39,7 @@ test "@shuffle" { |
| 39 | 39 | var v4: @Vector(2, bool) = [2]bool{ true, false }; |
| 40 | 40 | const mask5: @Vector(4, i32) = [4]i32{ 0, ~@as(i32, 1), 1, 2 }; |
| 41 | 41 | var res2 = @shuffle(bool, x2, v4, mask5); |
| 42 | expect(mem.eql(bool, @as([4]bool,res2), [4]bool{ false, false, true, false })); | |
| 42 | expect(mem.eql(bool, &@as([4]bool, res2), &[4]bool{ false, false, true, false })); | |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // TODO re-enable when LLVM codegen is fixed |
| ... | ... | @@ -49,7 +49,7 @@ test "@shuffle" { |
| 49 | 49 | var v4: @Vector(2, bool) = [2]bool{ true, false }; |
| 50 | 50 | const mask5: @Vector(4, i32) = [4]i32{ 0, ~@as(i32, 1), 1, 2 }; |
| 51 | 51 | var res2 = @shuffle(bool, x2, v4, mask5); |
| 52 | expect(mem.eql(bool, @as([4]bool,res2), [4]bool{ false, false, true, false })); | |
| 52 | expect(mem.eql(bool, &@as([4]bool, res2), &[4]bool{ false, false, true, false })); | |
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | }; |
test/stage1/behavior/slice.zig+3-3| ... | ... | @@ -28,7 +28,7 @@ fn sliceFromLenToLen(a_slice: []u8, start: usize, end: usize) []u8 { |
| 28 | 28 | |
| 29 | 29 | test "implicitly cast array of size 0 to slice" { |
| 30 | 30 | var msg = [_]u8{}; |
| 31 | assertLenIsZero(msg); | |
| 31 | assertLenIsZero(&msg); | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | fn assertLenIsZero(msg: []const u8) void { |
| ... | ... | @@ -51,8 +51,8 @@ fn sliceSum(comptime q: []const u8) i32 { |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | test "comptime slices are disambiguated" { |
| 54 | expect(sliceSum([_]u8{ 1, 2 }) == 3); | |
| 55 | expect(sliceSum([_]u8{ 3, 4 }) == 7); | |
| 54 | expect(sliceSum(&[_]u8{ 1, 2 }) == 3); | |
| 55 | expect(sliceSum(&[_]u8{ 3, 4 }) == 7); | |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | test "slice type with custom alignment" { |
test/stage1/behavior/struct.zig+5-4| ... | ... | @@ -184,7 +184,7 @@ fn testReturnEmptyStructFromFn() EmptyStruct2 { |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | test "pass slice of empty struct to fn" { |
| 187 | expect(testPassSliceOfEmptyStructToFn([_]EmptyStruct2{EmptyStruct2{}}) == 1); | |
| 187 | expect(testPassSliceOfEmptyStructToFn(&[_]EmptyStruct2{EmptyStruct2{}}) == 1); | |
| 188 | 188 | } |
| 189 | 189 | fn testPassSliceOfEmptyStructToFn(slice: []const EmptyStruct2) usize { |
| 190 | 190 | return slice.len; |
| ... | ... | @@ -432,7 +432,7 @@ const Expr = union(enum) { |
| 432 | 432 | }; |
| 433 | 433 | |
| 434 | 434 | fn alloc(comptime T: type) []T { |
| 435 | return [_]T{}; | |
| 435 | return &[_]T{}; | |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | test "call method with mutable reference to struct with no fields" { |
| ... | ... | @@ -495,7 +495,8 @@ test "non-byte-aligned array inside packed struct" { |
| 495 | 495 | .a = true, |
| 496 | 496 | .b = "abcdefghijklmnopqurstu".*, |
| 497 | 497 | }; |
| 498 | bar(foo.b); | |
| 498 | const value = foo.b; | |
| 499 | bar(&value); | |
| 499 | 500 | } |
| 500 | 501 | }; |
| 501 | 502 | S.doTheTest(); |
| ... | ... | @@ -783,7 +784,7 @@ test "struct with var field" { |
| 783 | 784 | x: var, |
| 784 | 785 | y: var, |
| 785 | 786 | }; |
| 786 | const pt = Point { | |
| 787 | const pt = Point{ | |
| 787 | 788 | .x = 1, |
| 788 | 789 | .y = 2, |
| 789 | 790 | }; |
test/stage1/behavior/struct_contains_slice_of_itself.zig+8-8| ... | ... | @@ -14,21 +14,21 @@ test "struct contains slice of itself" { |
| 14 | 14 | var other_nodes = [_]Node{ |
| 15 | 15 | Node{ |
| 16 | 16 | .payload = 31, |
| 17 | .children = [_]Node{}, | |
| 17 | .children = &[_]Node{}, | |
| 18 | 18 | }, |
| 19 | 19 | Node{ |
| 20 | 20 | .payload = 32, |
| 21 | .children = [_]Node{}, | |
| 21 | .children = &[_]Node{}, | |
| 22 | 22 | }, |
| 23 | 23 | }; |
| 24 | 24 | var nodes = [_]Node{ |
| 25 | 25 | Node{ |
| 26 | 26 | .payload = 1, |
| 27 | .children = [_]Node{}, | |
| 27 | .children = &[_]Node{}, | |
| 28 | 28 | }, |
| 29 | 29 | Node{ |
| 30 | 30 | .payload = 2, |
| 31 | .children = [_]Node{}, | |
| 31 | .children = &[_]Node{}, | |
| 32 | 32 | }, |
| 33 | 33 | Node{ |
| 34 | 34 | .payload = 3, |
| ... | ... | @@ -51,21 +51,21 @@ test "struct contains aligned slice of itself" { |
| 51 | 51 | var other_nodes = [_]NodeAligned{ |
| 52 | 52 | NodeAligned{ |
| 53 | 53 | .payload = 31, |
| 54 | .children = [_]NodeAligned{}, | |
| 54 | .children = &[_]NodeAligned{}, | |
| 55 | 55 | }, |
| 56 | 56 | NodeAligned{ |
| 57 | 57 | .payload = 32, |
| 58 | .children = [_]NodeAligned{}, | |
| 58 | .children = &[_]NodeAligned{}, | |
| 59 | 59 | }, |
| 60 | 60 | }; |
| 61 | 61 | var nodes = [_]NodeAligned{ |
| 62 | 62 | NodeAligned{ |
| 63 | 63 | .payload = 1, |
| 64 | .children = [_]NodeAligned{}, | |
| 64 | .children = &[_]NodeAligned{}, | |
| 65 | 65 | }, |
| 66 | 66 | NodeAligned{ |
| 67 | 67 | .payload = 2, |
| 68 | .children = [_]NodeAligned{}, | |
| 68 | .children = &[_]NodeAligned{}, | |
| 69 | 69 | }, |
| 70 | 70 | NodeAligned{ |
| 71 | 71 | .payload = 3, |
test/stage1/behavior/type.zig+12-12| ... | ... | @@ -12,22 +12,22 @@ fn testTypes(comptime types: []const type) void { |
| 12 | 12 | |
| 13 | 13 | test "Type.MetaType" { |
| 14 | 14 | testing.expect(type == @Type(TypeInfo{ .Type = undefined })); |
| 15 | testTypes([_]type{type}); | |
| 15 | testTypes(&[_]type{type}); | |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | test "Type.Void" { |
| 19 | 19 | testing.expect(void == @Type(TypeInfo{ .Void = undefined })); |
| 20 | testTypes([_]type{void}); | |
| 20 | testTypes(&[_]type{void}); | |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | test "Type.Bool" { |
| 24 | 24 | testing.expect(bool == @Type(TypeInfo{ .Bool = undefined })); |
| 25 | testTypes([_]type{bool}); | |
| 25 | testTypes(&[_]type{bool}); | |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | test "Type.NoReturn" { |
| 29 | 29 | testing.expect(noreturn == @Type(TypeInfo{ .NoReturn = undefined })); |
| 30 | testTypes([_]type{noreturn}); | |
| 30 | testTypes(&[_]type{noreturn}); | |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | test "Type.Int" { |
| ... | ... | @@ -37,7 +37,7 @@ test "Type.Int" { |
| 37 | 37 | testing.expect(i8 == @Type(TypeInfo{ .Int = TypeInfo.Int{ .is_signed = true, .bits = 8 } })); |
| 38 | 38 | testing.expect(u64 == @Type(TypeInfo{ .Int = TypeInfo.Int{ .is_signed = false, .bits = 64 } })); |
| 39 | 39 | testing.expect(i64 == @Type(TypeInfo{ .Int = TypeInfo.Int{ .is_signed = true, .bits = 64 } })); |
| 40 | testTypes([_]type{ u8, u32, i64 }); | |
| 40 | testTypes(&[_]type{ u8, u32, i64 }); | |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | test "Type.Float" { |
| ... | ... | @@ -45,11 +45,11 @@ test "Type.Float" { |
| 45 | 45 | testing.expect(f32 == @Type(TypeInfo{ .Float = TypeInfo.Float{ .bits = 32 } })); |
| 46 | 46 | testing.expect(f64 == @Type(TypeInfo{ .Float = TypeInfo.Float{ .bits = 64 } })); |
| 47 | 47 | testing.expect(f128 == @Type(TypeInfo{ .Float = TypeInfo.Float{ .bits = 128 } })); |
| 48 | testTypes([_]type{ f16, f32, f64, f128 }); | |
| 48 | testTypes(&[_]type{ f16, f32, f64, f128 }); | |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | test "Type.Pointer" { |
| 52 | testTypes([_]type{ | |
| 52 | testTypes(&[_]type{ | |
| 53 | 53 | // One Value Pointer Types |
| 54 | 54 | *u8, *const u8, |
| 55 | 55 | *volatile u8, *const volatile u8, |
| ... | ... | @@ -115,18 +115,18 @@ test "Type.Array" { |
| 115 | 115 | .sentinel = 0, |
| 116 | 116 | }, |
| 117 | 117 | })); |
| 118 | testTypes([_]type{ [1]u8, [30]usize, [7]bool }); | |
| 118 | testTypes(&[_]type{ [1]u8, [30]usize, [7]bool }); | |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | test "Type.ComptimeFloat" { |
| 122 | testTypes([_]type{comptime_float}); | |
| 122 | testTypes(&[_]type{comptime_float}); | |
| 123 | 123 | } |
| 124 | 124 | test "Type.ComptimeInt" { |
| 125 | testTypes([_]type{comptime_int}); | |
| 125 | testTypes(&[_]type{comptime_int}); | |
| 126 | 126 | } |
| 127 | 127 | test "Type.Undefined" { |
| 128 | testTypes([_]type{@typeOf(undefined)}); | |
| 128 | testTypes(&[_]type{@typeOf(undefined)}); | |
| 129 | 129 | } |
| 130 | 130 | test "Type.Null" { |
| 131 | testTypes([_]type{@typeOf(null)}); | |
| 131 | testTypes(&[_]type{@typeOf(null)}); | |
| 132 | 132 | } |
test/stage1/behavior/union.zig+1-1| ... | ... | @@ -241,7 +241,7 @@ pub const PackThis = union(enum) { |
| 241 | 241 | }; |
| 242 | 242 | |
| 243 | 243 | test "constant packed union" { |
| 244 | testConstPackedUnion([_]PackThis{PackThis{ .StringLiteral = 1 }}); | |
| 244 | testConstPackedUnion(&[_]PackThis{PackThis{ .StringLiteral = 1 }}); | |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | fn testConstPackedUnion(expected_tokens: []const PackThis) void { |
test/stage1/behavior/vector.zig+27-27| ... | ... | @@ -8,7 +8,7 @@ test "implicit cast vector to array - bool" { |
| 8 | 8 | fn doTheTest() void { |
| 9 | 9 | const a: @Vector(4, bool) = [_]bool{ true, false, true, false }; |
| 10 | 10 | const result_array: [4]bool = a; |
| 11 | expect(mem.eql(bool, result_array, [4]bool{ true, false, true, false })); | |
| 11 | expect(mem.eql(bool, &result_array, &[4]bool{ true, false, true, false })); | |
| 12 | 12 | } |
| 13 | 13 | }; |
| 14 | 14 | S.doTheTest(); |
| ... | ... | @@ -20,11 +20,11 @@ test "vector wrap operators" { |
| 20 | 20 | fn doTheTest() void { |
| 21 | 21 | var v: @Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 }; |
| 22 | 22 | var x: @Vector(4, i32) = [4]i32{ 1, 2147483647, 3, 4 }; |
| 23 | expect(mem.eql(i32, @as([4]i32, v +% x), [4]i32{ -2147483648, 2147483645, 33, 44 })); | |
| 24 | expect(mem.eql(i32, @as([4]i32, v -% x), [4]i32{ 2147483646, 2147483647, 27, 36 })); | |
| 25 | expect(mem.eql(i32, @as([4]i32, v *% x), [4]i32{ 2147483647, 2, 90, 160 })); | |
| 23 | expect(mem.eql(i32, &@as([4]i32, v +% x), &[4]i32{ -2147483648, 2147483645, 33, 44 })); | |
| 24 | expect(mem.eql(i32, &@as([4]i32, v -% x), &[4]i32{ 2147483646, 2147483647, 27, 36 })); | |
| 25 | expect(mem.eql(i32, &@as([4]i32, v *% x), &[4]i32{ 2147483647, 2, 90, 160 })); | |
| 26 | 26 | var z: @Vector(4, i32) = [4]i32{ 1, 2, 3, -2147483648 }; |
| 27 | expect(mem.eql(i32, @as([4]i32, -%z), [4]i32{ -1, -2, -3, -2147483648 })); | |
| 27 | expect(mem.eql(i32, &@as([4]i32, -%z), &[4]i32{ -1, -2, -3, -2147483648 })); | |
| 28 | 28 | } |
| 29 | 29 | }; |
| 30 | 30 | S.doTheTest(); |
| ... | ... | @@ -36,12 +36,12 @@ test "vector bin compares with mem.eql" { |
| 36 | 36 | fn doTheTest() void { |
| 37 | 37 | var v: @Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 }; |
| 38 | 38 | var x: @Vector(4, i32) = [4]i32{ 1, 2147483647, 30, 4 }; |
| 39 | expect(mem.eql(bool, @as([4]bool, v == x), [4]bool{ false, false, true, false })); | |
| 40 | expect(mem.eql(bool, @as([4]bool, v != x), [4]bool{ true, true, false, true })); | |
| 41 | expect(mem.eql(bool, @as([4]bool, v < x), [4]bool{ false, true, false, false })); | |
| 42 | expect(mem.eql(bool, @as([4]bool, v > x), [4]bool{ true, false, false, true })); | |
| 43 | expect(mem.eql(bool, @as([4]bool, v <= x), [4]bool{ false, true, true, false })); | |
| 44 | expect(mem.eql(bool, @as([4]bool, v >= x), [4]bool{ true, false, true, true })); | |
| 39 | expect(mem.eql(bool, &@as([4]bool, v == x), &[4]bool{ false, false, true, false })); | |
| 40 | expect(mem.eql(bool, &@as([4]bool, v != x), &[4]bool{ true, true, false, true })); | |
| 41 | expect(mem.eql(bool, &@as([4]bool, v < x), &[4]bool{ false, true, false, false })); | |
| 42 | expect(mem.eql(bool, &@as([4]bool, v > x), &[4]bool{ true, false, false, true })); | |
| 43 | expect(mem.eql(bool, &@as([4]bool, v <= x), &[4]bool{ false, true, true, false })); | |
| 44 | expect(mem.eql(bool, &@as([4]bool, v >= x), &[4]bool{ true, false, true, true })); | |
| 45 | 45 | } |
| 46 | 46 | }; |
| 47 | 47 | S.doTheTest(); |
| ... | ... | @@ -53,10 +53,10 @@ test "vector int operators" { |
| 53 | 53 | fn doTheTest() void { |
| 54 | 54 | var v: @Vector(4, i32) = [4]i32{ 10, 20, 30, 40 }; |
| 55 | 55 | var x: @Vector(4, i32) = [4]i32{ 1, 2, 3, 4 }; |
| 56 | expect(mem.eql(i32, @as([4]i32, v + x), [4]i32{ 11, 22, 33, 44 })); | |
| 57 | expect(mem.eql(i32, @as([4]i32, v - x), [4]i32{ 9, 18, 27, 36 })); | |
| 58 | expect(mem.eql(i32, @as([4]i32, v * x), [4]i32{ 10, 40, 90, 160 })); | |
| 59 | expect(mem.eql(i32, @as([4]i32, -v), [4]i32{ -10, -20, -30, -40 })); | |
| 56 | expect(mem.eql(i32, &@as([4]i32, v + x), &[4]i32{ 11, 22, 33, 44 })); | |
| 57 | expect(mem.eql(i32, &@as([4]i32, v - x), &[4]i32{ 9, 18, 27, 36 })); | |
| 58 | expect(mem.eql(i32, &@as([4]i32, v * x), &[4]i32{ 10, 40, 90, 160 })); | |
| 59 | expect(mem.eql(i32, &@as([4]i32, -v), &[4]i32{ -10, -20, -30, -40 })); | |
| 60 | 60 | } |
| 61 | 61 | }; |
| 62 | 62 | S.doTheTest(); |
| ... | ... | @@ -68,10 +68,10 @@ test "vector float operators" { |
| 68 | 68 | fn doTheTest() void { |
| 69 | 69 | var v: @Vector(4, f32) = [4]f32{ 10, 20, 30, 40 }; |
| 70 | 70 | var x: @Vector(4, f32) = [4]f32{ 1, 2, 3, 4 }; |
| 71 | expect(mem.eql(f32, @as([4]f32, v + x), [4]f32{ 11, 22, 33, 44 })); | |
| 72 | expect(mem.eql(f32, @as([4]f32, v - x), [4]f32{ 9, 18, 27, 36 })); | |
| 73 | expect(mem.eql(f32, @as([4]f32, v * x), [4]f32{ 10, 40, 90, 160 })); | |
| 74 | expect(mem.eql(f32, @as([4]f32, -x), [4]f32{ -1, -2, -3, -4 })); | |
| 71 | expect(mem.eql(f32, &@as([4]f32, v + x), &[4]f32{ 11, 22, 33, 44 })); | |
| 72 | expect(mem.eql(f32, &@as([4]f32, v - x), &[4]f32{ 9, 18, 27, 36 })); | |
| 73 | expect(mem.eql(f32, &@as([4]f32, v * x), &[4]f32{ 10, 40, 90, 160 })); | |
| 74 | expect(mem.eql(f32, &@as([4]f32, -x), &[4]f32{ -1, -2, -3, -4 })); | |
| 75 | 75 | } |
| 76 | 76 | }; |
| 77 | 77 | S.doTheTest(); |
| ... | ... | @@ -83,9 +83,9 @@ test "vector bit operators" { |
| 83 | 83 | fn doTheTest() void { |
| 84 | 84 | var v: @Vector(4, u8) = [4]u8{ 0b10101010, 0b10101010, 0b10101010, 0b10101010 }; |
| 85 | 85 | var x: @Vector(4, u8) = [4]u8{ 0b11110000, 0b00001111, 0b10101010, 0b01010101 }; |
| 86 | expect(mem.eql(u8, @as([4]u8, v ^ x), [4]u8{ 0b01011010, 0b10100101, 0b00000000, 0b11111111 })); | |
| 87 | expect(mem.eql(u8, @as([4]u8, v | x), [4]u8{ 0b11111010, 0b10101111, 0b10101010, 0b11111111 })); | |
| 88 | expect(mem.eql(u8, @as([4]u8, v & x), [4]u8{ 0b10100000, 0b00001010, 0b10101010, 0b00000000 })); | |
| 86 | expect(mem.eql(u8, &@as([4]u8, v ^ x), &[4]u8{ 0b01011010, 0b10100101, 0b00000000, 0b11111111 })); | |
| 87 | expect(mem.eql(u8, &@as([4]u8, v | x), &[4]u8{ 0b11111010, 0b10101111, 0b10101010, 0b11111111 })); | |
| 88 | expect(mem.eql(u8, &@as([4]u8, v & x), &[4]u8{ 0b10100000, 0b00001010, 0b10101010, 0b00000000 })); | |
| 89 | 89 | } |
| 90 | 90 | }; |
| 91 | 91 | S.doTheTest(); |
| ... | ... | @@ -98,7 +98,7 @@ test "implicit cast vector to array" { |
| 98 | 98 | var a: @Vector(4, i32) = [_]i32{ 1, 2, 3, 4 }; |
| 99 | 99 | var result_array: [4]i32 = a; |
| 100 | 100 | result_array = a; |
| 101 | expect(mem.eql(i32, result_array, [4]i32{ 1, 2, 3, 4 })); | |
| 101 | expect(mem.eql(i32, &result_array, &[4]i32{ 1, 2, 3, 4 })); | |
| 102 | 102 | } |
| 103 | 103 | }; |
| 104 | 104 | S.doTheTest(); |
| ... | ... | @@ -120,22 +120,22 @@ test "vector casts of sizes not divisable by 8" { |
| 120 | 120 | { |
| 121 | 121 | var v: @Vector(4, u3) = [4]u3{ 5, 2, 3, 0 }; |
| 122 | 122 | var x: [4]u3 = v; |
| 123 | expect(mem.eql(u3, x, @as([4]u3, v))); | |
| 123 | expect(mem.eql(u3, &x, &@as([4]u3, v))); | |
| 124 | 124 | } |
| 125 | 125 | { |
| 126 | 126 | var v: @Vector(4, u2) = [4]u2{ 1, 2, 3, 0 }; |
| 127 | 127 | var x: [4]u2 = v; |
| 128 | expect(mem.eql(u2, x, @as([4]u2, v))); | |
| 128 | expect(mem.eql(u2, &x, &@as([4]u2, v))); | |
| 129 | 129 | } |
| 130 | 130 | { |
| 131 | 131 | var v: @Vector(4, u1) = [4]u1{ 1, 0, 1, 0 }; |
| 132 | 132 | var x: [4]u1 = v; |
| 133 | expect(mem.eql(u1, x, @as([4]u1, v))); | |
| 133 | expect(mem.eql(u1, &x, &@as([4]u1, v))); | |
| 134 | 134 | } |
| 135 | 135 | { |
| 136 | 136 | var v: @Vector(4, bool) = [4]bool{ false, false, true, false }; |
| 137 | 137 | var x: [4]bool = v; |
| 138 | expect(mem.eql(bool, x, @as([4]bool, v))); | |
| 138 | expect(mem.eql(bool, &x, &@as([4]bool, v))); | |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | }; |
test/tests.zig+16-16| ... | ... | @@ -325,7 +325,7 @@ pub fn addCliTests(b: *build.Builder, test_filter: ?[]const u8, modes: []const M |
| 325 | 325 | |
| 326 | 326 | const exe = b.addExecutable("test-cli", "test/cli.zig"); |
| 327 | 327 | const run_cmd = exe.run(); |
| 328 | run_cmd.addArgs([_][]const u8{ | |
| 328 | run_cmd.addArgs(&[_][]const u8{ | |
| 329 | 329 | fs.realpathAlloc(b.allocator, b.zig_exe) catch unreachable, |
| 330 | 330 | b.pathFromRoot(b.cache_root), |
| 331 | 331 | }); |
| ... | ... | @@ -411,7 +411,7 @@ pub fn addPkgTests( |
| 411 | 411 | const ArchTag = @TagType(builtin.Arch); |
| 412 | 412 | if (test_target.disable_native and |
| 413 | 413 | test_target.target.getOs() == builtin.os and |
| 414 | @as(ArchTag,test_target.target.getArch()) == @as(ArchTag,builtin.arch)) | |
| 414 | @as(ArchTag, test_target.target.getArch()) == @as(ArchTag, builtin.arch)) | |
| 415 | 415 | { |
| 416 | 416 | continue; |
| 417 | 417 | } |
| ... | ... | @@ -429,7 +429,7 @@ pub fn addPkgTests( |
| 429 | 429 | "bare"; |
| 430 | 430 | |
| 431 | 431 | const triple_prefix = if (test_target.target == .Native) |
| 432 | @as([]const u8,"native") | |
| 432 | @as([]const u8, "native") | |
| 433 | 433 | else |
| 434 | 434 | test_target.target.zigTripleNoSubArch(b.allocator) catch unreachable; |
| 435 | 435 | |
| ... | ... | @@ -626,7 +626,7 @@ pub const CompareOutputContext = struct { |
| 626 | 626 | |
| 627 | 627 | warn("Test {}/{} {}...", self.test_index + 1, self.context.test_index, self.name); |
| 628 | 628 | |
| 629 | const child = std.ChildProcess.init([_][]const u8{full_exe_path}, b.allocator) catch unreachable; | |
| 629 | const child = std.ChildProcess.init(&[_][]const u8{full_exe_path}, b.allocator) catch unreachable; | |
| 630 | 630 | defer child.deinit(); |
| 631 | 631 | |
| 632 | 632 | child.env_map = b.env_map; |
| ... | ... | @@ -667,7 +667,7 @@ pub const CompareOutputContext = struct { |
| 667 | 667 | .expected_output = expected_output, |
| 668 | 668 | .link_libc = false, |
| 669 | 669 | .special = special, |
| 670 | .cli_args = [_][]const u8{}, | |
| 670 | .cli_args = &[_][]const u8{}, | |
| 671 | 671 | }; |
| 672 | 672 | const root_src_name = if (special == Special.Asm) "source.s" else "source.zig"; |
| 673 | 673 | tc.addSourceFile(root_src_name, source); |
| ... | ... | @@ -704,7 +704,7 @@ pub const CompareOutputContext = struct { |
| 704 | 704 | |
| 705 | 705 | const root_src = fs.path.join( |
| 706 | 706 | b.allocator, |
| 707 | [_][]const u8{ b.cache_root, case.sources.items[0].filename }, | |
| 707 | &[_][]const u8{ b.cache_root, case.sources.items[0].filename }, | |
| 708 | 708 | ) catch unreachable; |
| 709 | 709 | |
| 710 | 710 | switch (case.special) { |
| ... | ... | @@ -720,7 +720,7 @@ pub const CompareOutputContext = struct { |
| 720 | 720 | for (case.sources.toSliceConst()) |src_file| { |
| 721 | 721 | const expanded_src_path = fs.path.join( |
| 722 | 722 | b.allocator, |
| 723 | [_][]const u8{ b.cache_root, src_file.filename }, | |
| 723 | &[_][]const u8{ b.cache_root, src_file.filename }, | |
| 724 | 724 | ) catch unreachable; |
| 725 | 725 | const write_src = b.addWriteFile(expanded_src_path, src_file.source); |
| 726 | 726 | exe.step.dependOn(&write_src.step); |
| ... | ... | @@ -752,7 +752,7 @@ pub const CompareOutputContext = struct { |
| 752 | 752 | for (case.sources.toSliceConst()) |src_file| { |
| 753 | 753 | const expanded_src_path = fs.path.join( |
| 754 | 754 | b.allocator, |
| 755 | [_][]const u8{ b.cache_root, src_file.filename }, | |
| 755 | &[_][]const u8{ b.cache_root, src_file.filename }, | |
| 756 | 756 | ) catch unreachable; |
| 757 | 757 | const write_src = b.addWriteFile(expanded_src_path, src_file.source); |
| 758 | 758 | exe.step.dependOn(&write_src.step); |
| ... | ... | @@ -783,7 +783,7 @@ pub const CompareOutputContext = struct { |
| 783 | 783 | for (case.sources.toSliceConst()) |src_file| { |
| 784 | 784 | const expanded_src_path = fs.path.join( |
| 785 | 785 | b.allocator, |
| 786 | [_][]const u8{ b.cache_root, src_file.filename }, | |
| 786 | &[_][]const u8{ b.cache_root, src_file.filename }, | |
| 787 | 787 | ) catch unreachable; |
| 788 | 788 | const write_src = b.addWriteFile(expanded_src_path, src_file.source); |
| 789 | 789 | exe.step.dependOn(&write_src.step); |
| ... | ... | @@ -816,7 +816,7 @@ pub const StackTracesContext = struct { |
| 816 | 816 | |
| 817 | 817 | const source_pathname = fs.path.join( |
| 818 | 818 | b.allocator, |
| 819 | [_][]const u8{ b.cache_root, "source.zig" }, | |
| 819 | &[_][]const u8{ b.cache_root, "source.zig" }, | |
| 820 | 820 | ) catch unreachable; |
| 821 | 821 | |
| 822 | 822 | for (self.modes) |mode| { |
| ... | ... | @@ -1073,7 +1073,7 @@ pub const CompileErrorContext = struct { |
| 1073 | 1073 | |
| 1074 | 1074 | const root_src = fs.path.join( |
| 1075 | 1075 | b.allocator, |
| 1076 | [_][]const u8{ b.cache_root, self.case.sources.items[0].filename }, | |
| 1076 | &[_][]const u8{ b.cache_root, self.case.sources.items[0].filename }, | |
| 1077 | 1077 | ) catch unreachable; |
| 1078 | 1078 | |
| 1079 | 1079 | var zig_args = ArrayList([]const u8).init(b.allocator); |
| ... | ... | @@ -1270,7 +1270,7 @@ pub const CompileErrorContext = struct { |
| 1270 | 1270 | for (case.sources.toSliceConst()) |src_file| { |
| 1271 | 1271 | const expanded_src_path = fs.path.join( |
| 1272 | 1272 | b.allocator, |
| 1273 | [_][]const u8{ b.cache_root, src_file.filename }, | |
| 1273 | &[_][]const u8{ b.cache_root, src_file.filename }, | |
| 1274 | 1274 | ) catch unreachable; |
| 1275 | 1275 | const write_src = b.addWriteFile(expanded_src_path, src_file.source); |
| 1276 | 1276 | compile_and_cmp_errors.step.dependOn(&write_src.step); |
| ... | ... | @@ -1404,7 +1404,7 @@ pub const TranslateCContext = struct { |
| 1404 | 1404 | |
| 1405 | 1405 | const root_src = fs.path.join( |
| 1406 | 1406 | b.allocator, |
| 1407 | [_][]const u8{ b.cache_root, self.case.sources.items[0].filename }, | |
| 1407 | &[_][]const u8{ b.cache_root, self.case.sources.items[0].filename }, | |
| 1408 | 1408 | ) catch unreachable; |
| 1409 | 1409 | |
| 1410 | 1410 | var zig_args = ArrayList([]const u8).init(b.allocator); |
| ... | ... | @@ -1577,7 +1577,7 @@ pub const TranslateCContext = struct { |
| 1577 | 1577 | for (case.sources.toSliceConst()) |src_file| { |
| 1578 | 1578 | const expanded_src_path = fs.path.join( |
| 1579 | 1579 | b.allocator, |
| 1580 | [_][]const u8{ b.cache_root, src_file.filename }, | |
| 1580 | &[_][]const u8{ b.cache_root, src_file.filename }, | |
| 1581 | 1581 | ) catch unreachable; |
| 1582 | 1582 | const write_src = b.addWriteFile(expanded_src_path, src_file.source); |
| 1583 | 1583 | translate_c_and_cmp.step.dependOn(&write_src.step); |
| ... | ... | @@ -1700,7 +1700,7 @@ pub const GenHContext = struct { |
| 1700 | 1700 | const b = self.b; |
| 1701 | 1701 | const root_src = fs.path.join( |
| 1702 | 1702 | b.allocator, |
| 1703 | [_][]const u8{ b.cache_root, case.sources.items[0].filename }, | |
| 1703 | &[_][]const u8{ b.cache_root, case.sources.items[0].filename }, | |
| 1704 | 1704 | ) catch unreachable; |
| 1705 | 1705 | |
| 1706 | 1706 | const mode = builtin.Mode.Debug; |
| ... | ... | @@ -1715,7 +1715,7 @@ pub const GenHContext = struct { |
| 1715 | 1715 | for (case.sources.toSliceConst()) |src_file| { |
| 1716 | 1716 | const expanded_src_path = fs.path.join( |
| 1717 | 1717 | b.allocator, |
| 1718 | [_][]const u8{ b.cache_root, src_file.filename }, | |
| 1718 | &[_][]const u8{ b.cache_root, src_file.filename }, | |
| 1719 | 1719 | ) catch unreachable; |
| 1720 | 1720 | const write_src = b.addWriteFile(expanded_src_path, src_file.source); |
| 1721 | 1721 | obj.step.dependOn(&write_src.step); |