You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the following code produces garbage when I run it:
const std = @import("std");
const Foobar = struct {
const Self = @This();
myTypes: [128]type,
str: [1024]u8,
str_len: usize,
fn from(comptime s: []const u8) Self {
comptime var foobar: Foobar = undefined;
std.mem.copy(u8, &foobar.str, s);
foobar.str_len = s.len;
return foobar;
}
fn getString(comptime self: *Self) []const u8 {
return self.str[0..self.str_len];
}
};
pub fn main() anyerror!void {
comptime var foobar = Foobar.from(
\\ Enim tempora est occaecati aut delectus quibusdam modi saepe. Fugiat odit id autem et praesentium provident. Iure voluptas explicabo ipsa provident eaque. Repellat dolorum voluptatem velit harum alias nobis quo et. Sit doloribus sit molestias. Dolorem laborum eligendi aut.
);
std.debug.print("foobar: {}\n", .{foobar.getString()});
}
I get this output:
foobar: 0+ *1 10 01 D1 0
1 / ! / 0
but if I comment the line myTypes: [128]type it works fine:
foobar: Enim tempora est occaecati aut delectus quibusdam modi saepe. Fugiat odit id autem et praesentium provident. Iure voluptas explicabo ipsa provident eaque. Repellat dolorum voluptatem velit harum alias nobis quo et. Sit doloribus sit molestias. Dolorem laborum eligendi aut.
The text was updated successfully, but these errors were encountered:
alexnask
added
bug
Observed behavior contradicts documented or intended behavior
stage1
The process of building from source via WebAssembly and the C backend.
labels
Nov 8, 2020
Hello,
the following code produces garbage when I run it:
I get this output:
but if I comment the line
myTypes: [128]type
it works fine:The text was updated successfully, but these errors were encountered: