In typed AST, address-of operations are now always represented by
nkAddr trees. This simplifies some compiler logic, makes processing
for typed macros easier, and fixes an effect tracking bug with addr.
Details
This is effectively a revert of
https://github.com/nim-lang/nim/pull/10814.
Not turning calls to mAddr into nkAddr was done to prevent the
unsafe address semantics from being lost, but those no longer exist.
Lowering the call into an nkAddr tree has the benefit that it
simplifies AST analysis and processing, as address-of operation can now
always be detected by PNode.kind == nkAddr. Old code for detecting
mAddr magic calls is removed.
The effect tracking in sempass2 had no special case for mAddr
calls, thus treating them as normal calls, which led to addr(x) being
treated as an indirect invocation of x, when x is of procedural
type. With the mAddr call now being lowered earlier, this is no
longer the case.
Summary
In typed AST, address-of operations are now always represented by
nkAddr
trees. This simplifies some compiler logic, makes processing for typed macros easier, and fixes an effect tracking bug withaddr
.Details
This is effectively a revert of https://github.com/nim-lang/nim/pull/10814. Not turning calls to
mAddr
intonkAddr
was done to prevent the unsafe address semantics from being lost, but those no longer exist.Lowering the call into an
nkAddr
tree has the benefit that it simplifies AST analysis and processing, as address-of operation can now always be detected byPNode.kind == nkAddr
. Old code for detectingmAddr
magic calls is removed.The effect tracking in
sempass2
had no special case formAddr
calls, thus treating them as normal calls, which led toaddr(x)
being treated as an indirect invocation ofx
, whenx
is of procedural type. With themAddr
call now being lowered earlier, this is no longer the case.