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
Here is some code which can crash in several ways. It depends on which field(s) in the SystemData struct are optional. If the second field is optional, but the first isn't, I get this:
Entry block to function must not have predecessors!
label %Entry
LLVM ERROR: Broken module found, compilation aborted!
The following command exited with error code 1:
zig test /home/dbandstra/oxid/test.zig --library c
If the other field is optional instead, or if both are optional, I get a crash with no error message (probably a straight crash, not failed assert). If neither field is optional, it doesn't crash.
See comments where I've noted code that can be removed to dodge the crash.
const builtin = @import("builtin");
const ComponentA = struct{ unused: u32 };
const ComponentB = struct{ unused: u32 };
const SystemData = struct{
a: *ComponentA,
b: ?*ComponentB,
};
test "" {
// if this variable is `comptime`, it works (this is actually what I should be doing)
var all_fields_optional = true;
inline for (@typeInfo(SystemData).Struct.fields) |field| {
if (@typeId(field.field_type) == builtin.TypeId.Optional) {
all_fields_optional = false;
}
}
inline for (@typeInfo(SystemData).Struct.fields) |field| {
// if `and !all_fields_optional` is removed, it works
if (@typeId(field.field_type) == builtin.TypeId.Optional and !all_fields_optional) {
continue;
}
// ...
}
}
The text was updated successfully, but these errors were encountered:
andrewrk
added
the
bug
Observed behavior contradicts documented or intended behavior
label
Sep 3, 2018
Here is some code which can crash in several ways. It depends on which field(s) in the
SystemData
struct are optional. If the second field is optional, but the first isn't, I get this:If the other field is optional instead, or if both are optional, I get a crash with no error message (probably a straight crash, not failed assert). If neither field is optional, it doesn't crash.
See comments where I've noted code that can be removed to dodge the crash.
The text was updated successfully, but these errors were encountered: