-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## 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 nim-lang/Nim#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.
- Loading branch information
Showing
7 changed files
with
25 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
discard """ | ||
description: ''' | ||
Taking the address of a location storing a procedural value does not | ||
incur the procedure's effects. | ||
''' | ||
action: compile | ||
""" | ||
|
||
proc p() {.raises: [].} = | ||
var a: proc() {.raises: ValueError.} | ||
discard addr(a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters