nim-works / nimskull

An in development statically typed systems programming language; with sustainability at its core. We, the community of users, maintain it.
https://nim-works.github.io/nimskull/index.html
Other
279 stars 39 forks source link

sem: replace `addr` calls with `nkAddr` #1465

Closed zerbina closed 1 month ago

zerbina commented 1 month ago

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 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.

saem commented 1 month ago

/merge

github-actions[bot] commented 1 month ago

Merge requested by: @saem

Contents after the first section break of the PR description has been removed and preserved below:


## Notes for Reviewers * unblocks #1464