-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Milestone
Description
I found this out while trying to use ZPM to add a package. This is not a ZPM bug as I found, but rather a bug in Zig's std.mem.concat.
Below is a simplified version of the error
const std = @import("std");
pub fn main() !void {
const name = try std.io.getStdIn().reader().readUntilDelimiterAlloc(std.heap.page_allocator, '\n', 512);
defer std.heap.page_allocator.free(name);
std.debug.warn("\n", .{});
var path = try std.mem.concat(std.heap.page_allocator, u8, &[_][]const u8{
"packages/",
name,
".json",
});
std.debug.warn("{}\n", .{path});
}Input: myPackage
Output on Ubuntu 20.04: packages/myPackage.zig
Output on Windows: .jsonges/myPackage.zig
This means that the ".json" is overwriting the beginning of the buffer. What's weirder is that when iterating through the entire buffer when copying, every character is printed as the correct string packages/myPackage.zig but the returned result is the other bugged version.
Metadata
Metadata
Assignees
Labels
standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.