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
conststd=@import("std");
constwarn=std.debug.warn;
constT=struct{};
constU=struct {
str: []constu8,
fnf(self: *U) ?T {
varstr=self.str;
returnstr[0..1];
}
fng(self: *U) ?T {
if (self.f()) |e|returne;
returnnull;
}
};
pubfnmain() void { // return type can also be 'anyerror!void' as well -- still crashes.varu=U{ .str="" };
// Either of these crashes the compiler.// if (u.f()) |e| return e; // if (u.g()) |e| warn("{}\n", e);warn("done\n");
}
The text was updated successfully, but these errors were encountered:
There's a possibly related problem that causes invalid LLVM IR to be generated, which is what I was originally trying to reproduce when I came across this; this outright crashes rather than generating bad IR though.
andrewrk
added
bug
Observed behavior contradicts documented or intended behavior
stage1
The process of building from source via WebAssembly and the C backend.
labels
Sep 19, 2019
./build/a.zig:45:27: error: expected type 'void', found 'T'
if (u.f()) |e| return e;
^
./build/a.zig:25:11: note: T declared here
const T = struct{};
^
./build/a.zig:32:19: error: expected type 'T', found '[]const u8'
return str[0..1];
^
./build/a.zig:25:11: note: T declared here
const T = struct{};
^
The text was updated successfully, but these errors were encountered: