Sema: validate equality on store to comptime field
This commit is contained in:
committed by
Andrew Kelley
parent
a040ccb42f
commit
cb5d2b691a
@@ -1336,3 +1336,25 @@ test "packed struct field access via pointer" {
|
||||
try S.doTheTest();
|
||||
comptime try S.doTheTest();
|
||||
}
|
||||
|
||||
test "store to comptime field" {
|
||||
if (builtin.zig_backend == .stage1) return error.SkipZigTest;
|
||||
|
||||
{
|
||||
const S = struct {
|
||||
comptime a: [2]u32 = [2]u32{ 1, 2 },
|
||||
};
|
||||
var s: S = .{};
|
||||
s.a = [2]u32{ 1, 2 };
|
||||
s.a[0] = 1;
|
||||
}
|
||||
{
|
||||
const T = struct { a: u32, b: u32 };
|
||||
const S = struct {
|
||||
comptime a: T = T{ .a = 1, .b = 2 },
|
||||
};
|
||||
var s: S = .{};
|
||||
s.a = T{ .a = 1, .b = 2 };
|
||||
s.a.a = 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user