AstGen: make comptime fields in packed and extern structs compile errors
This commit is contained in:
21
test/cases/compile_errors/invalid_comptime_fields.zig
Normal file
21
test/cases/compile_errors/invalid_comptime_fields.zig
Normal file
@@ -0,0 +1,21 @@
|
||||
const U = union {
|
||||
comptime a: u32 = 1,
|
||||
};
|
||||
const E = enum {
|
||||
comptime a = 1,
|
||||
};
|
||||
const P = packed struct {
|
||||
comptime a: u32 = 1,
|
||||
};
|
||||
const X = extern struct {
|
||||
comptime a: u32 = 1,
|
||||
};
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :2:5: error: union fields cannot be marked comptime
|
||||
// :5:5: error: enum fields cannot be marked comptime
|
||||
// :8:5: error: packed struct fields cannot be marked comptime
|
||||
// :11:5: error: extern struct fields cannot be marked comptime
|
||||
Reference in New Issue
Block a user