mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 22:35:24 +00:00
Sema: handle empty_struct_value in beginComptimePtrMutation
Closes #12794
This commit is contained in:
parent
61aaef0b07
commit
de24cea2cf
14
src/Sema.zig
14
src/Sema.zig
@ -24770,6 +24770,20 @@ fn beginComptimePtrMutation(
|
||||
else => unreachable,
|
||||
},
|
||||
|
||||
.empty_struct_value => {
|
||||
const duped = try sema.arena.create(Value);
|
||||
duped.* = Value.initTag(.the_only_possible_value);
|
||||
return beginComptimePtrMutationInner(
|
||||
sema,
|
||||
block,
|
||||
src,
|
||||
parent.ty.structFieldType(field_index),
|
||||
duped,
|
||||
ptr_elem_ty,
|
||||
parent.decl_ref_mut,
|
||||
);
|
||||
},
|
||||
|
||||
else => unreachable,
|
||||
},
|
||||
.reinterpret => |reinterpret| {
|
||||
|
||||
@ -87,6 +87,7 @@ test {
|
||||
_ = @import("behavior/bugs/12486.zig");
|
||||
_ = @import("behavior/bugs/12680.zig");
|
||||
_ = @import("behavior/bugs/12776.zig");
|
||||
_ = @import("behavior/bugs/12794.zig");
|
||||
_ = @import("behavior/byteswap.zig");
|
||||
_ = @import("behavior/byval_arg_var.zig");
|
||||
_ = @import("behavior/call.zig");
|
||||
|
||||
38
test/behavior/bugs/12794.zig
Normal file
38
test/behavior/bugs/12794.zig
Normal file
@ -0,0 +1,38 @@
|
||||
const std = @import("std");
|
||||
|
||||
fn NamespacedComponents(comptime modules: anytype) type {
|
||||
return @Type(.{
|
||||
.Struct = .{
|
||||
.layout = .Auto,
|
||||
.is_tuple = false,
|
||||
.fields = &.{.{
|
||||
.name = "components",
|
||||
.field_type = @TypeOf(modules.components),
|
||||
.default_value = null,
|
||||
.is_comptime = false,
|
||||
.alignment = @alignOf(@TypeOf(modules.components)),
|
||||
}},
|
||||
.decls = &[_]std.builtin.Type.Declaration{},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
fn namespacedComponents(comptime modules: anytype) NamespacedComponents(modules) {
|
||||
var x: NamespacedComponents(modules) = undefined;
|
||||
x.components = modules.components;
|
||||
return x;
|
||||
}
|
||||
|
||||
pub fn World(comptime modules: anytype) type {
|
||||
const all_components = namespacedComponents(modules);
|
||||
_ = all_components;
|
||||
return struct {};
|
||||
}
|
||||
|
||||
test {
|
||||
_ = World(.{
|
||||
.components = .{
|
||||
.location = struct {},
|
||||
},
|
||||
});
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user