Open
Description
Zig Version
0.14.0-dev.2371+c013f45ad
Steps to Reproduce and Observed Output
Current reproduction:
comptime {
const x: u8 = 0;
_ = @intFromPtr(&x);
}
Current compile error output:
.zig:3:9: error: unable to evaluate comptime expression
_ = @intFromPtr(&x);
^~~~~~~~~~~~~~~
.zig:3:21: note: operation is runtime due to this operand
_ = @intFromPtr(&x);
^~
The note is somewhat misleading, because nothing about this operand is runtime.
It seems to me like the error note logic was copied from some other operation without much thought.
What's actually happening is that @intFromPtr
itself is currently restricted to runtime contexts.
(See #15080, the plan is to eventually implement workaround semantics for comptime
.)
Expected Output
Something along the lines of:
.zig:3:9: error: unable to evaluate comptime expression
_ = @intFromPtr(&x);
^~~~~~~~~~~~~~~
.zig:3:21: note: @intFromPtr is currently only available at runtime