diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-10-05 15:06:14 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-10-06 20:09:45 +0300 |
| commit | 94039d66ed4fecb7defc5deeeedd7afa3b773f0c (patch) | |
| tree | 59e0c2a2033972bdf2ba22a76db7b1236a82dcc5 /test | |
| parent | cc89908e826882065eeaa23bb8827fb7d7cd6219 (diff) | |
| download | zig-94039d66ed4fecb7defc5deeeedd7afa3b773f0c.tar.gz zig-94039d66ed4fecb7defc5deeeedd7afa3b773f0c.zip | |
Sema: disallow fieldParentPtr and offsetOf on comptime fields
Comptime fields are tied to the type and behave more like declarations
so these operations cannot return anything useful for them.
Diffstat (limited to 'test')
| -rw-r--r-- | test/cases/compile_errors/fieldParentPtr_on_comptime_field.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/cases/compile_errors/fieldParentPtr_on_comptime_field.zig b/test/cases/compile_errors/fieldParentPtr_on_comptime_field.zig new file mode 100644 index 0000000000..fb95ea691c --- /dev/null +++ b/test/cases/compile_errors/fieldParentPtr_on_comptime_field.zig @@ -0,0 +1,16 @@ +const T = struct { + comptime a: u32 = 2, +}; +pub export fn entry1() void { + @offsetOf(T, "a"); +} +pub export fn entry2() void { + @fieldParentPtr(T, "a", undefined); +} + +// error +// backend=stage2 +// target=native +// +// :5:5: error: no offset available for comptime field +// :8:5: error: cannot get @fieldParentPtr of a comptime field |
