You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sema uses the requireRuntimeBlock function to emit a compile error when performing a runtime operation in a comptime block. However, most uses of this function are actually incorrect. The consensus Andrew and I have reached, to make sure expressions like comptime runtime_array.len work, is that non-side-effecting expressions are allowed to be runtime-known in a comptime scope. It's never possible for a runtime value to be "leaked" out of a comptime block, nor to be meaningfully used within one, so this never allows a comptime scope to actually emit real runtime code (Sema discards instructions of the Block being comptime-evaluated).
All uses of requireRuntimeBlock need to be audited, and the majority simply removed. The only ones remaining should be those which have side effects, such as storing to a runtime pointer.
The text was updated successfully, but these errors were encountered:
mlugg
added
bug
Observed behavior contradicts documented or intended behavior
frontend
Tokenization, parsing, AstGen, Sema, and Liveness.
labels
Dec 29, 2024
Most calls to `requireRuntimeBlock` in Sema are not correct. This
function doesn't deal with all of them, but it does deal with ones which
have, in combination with the past few commits, introduced real-world
regressions.
Related: ziglang#22353
mlugg
added a commit
to mlugg/zig
that referenced
this issue
Dec 30, 2024
Most calls to `requireRuntimeBlock` in Sema are not correct. This
function doesn't deal with all of them, but it does deal with ones which
have, in combination with the past few commits, introduced real-world
regressions.
Related: ziglang#22353
mlugg
added a commit
to mlugg/zig
that referenced
this issue
Dec 30, 2024
Most calls to `requireRuntimeBlock` in Sema are not correct. This
function doesn't deal with all of them, but it does deal with ones which
have, in combination with the past few commits, introduced real-world
regressions.
Related: ziglang#22353
mlugg
added a commit
to mlugg/zig
that referenced
this issue
Dec 31, 2024
Most calls to `requireRuntimeBlock` in Sema are not correct. This
function doesn't deal with all of them, but it does deal with ones which
have, in combination with the past few commits, introduced real-world
regressions.
Related: ziglang#22353
Sema uses the
requireRuntimeBlock
function to emit a compile error when performing a runtime operation in a comptime block. However, most uses of this function are actually incorrect. The consensus Andrew and I have reached, to make sure expressions likecomptime runtime_array.len
work, is that non-side-effecting expressions are allowed to be runtime-known in acomptime
scope. It's never possible for a runtime value to be "leaked" out of acomptime
block, nor to be meaningfully used within one, so this never allows acomptime
scope to actually emit real runtime code (Sema discardsinstructions
of theBlock
being comptime-evaluated).All uses of
requireRuntimeBlock
need to be audited, and the majority simply removed. The only ones remaining should be those which have side effects, such as storing to a runtime pointer.The text was updated successfully, but these errors were encountered: