Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsafeaddr rendered as addr in typed AST #10807

Closed
cooldome opened this issue Mar 7, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@cooldome
Copy link
Member

commented Mar 7, 2019

Example:

import macros

proc test_unsafeaddr(x: int): int = 
  cast[int](unsafeAddr(x))

macro dumpSym(someproc: typed): untyped = 
  echo someproc.getImpl.repr

dumpSym(test_unsafeaddr)

test_unsafeaddr rendered as:

proc test_unsafeaddr(x: int): int =
  result = cast[int](addr(x))

unsafety of addr is lost.

@cooldome cooldome added the Macros label Mar 7, 2019

@cooldome

This comment has been minimized.

Copy link
Member Author

commented Mar 7, 2019

@Araq:
In order to fix this one looks like new node kind will be required. Are you ok with such solution?

@Araq

This comment has been minimized.

Copy link
Member

commented Mar 8, 2019

I think we can instead make the backends aware of mAddr magic instead of an nkAddr node kind.

@cooldome

This comment has been minimized.

Copy link
Member Author

commented Mar 9, 2019

Make sense. I will do exactly that.

cooldome added a commit to cooldome/Nim that referenced this issue Mar 9, 2019

@Araq Araq closed this in 8ceba8a Mar 12, 2019

c-blake pushed a commit to c-blake/cligen that referenced this issue Mar 13, 2019

Charles Blake
PR nim-lang/Nim#10814 responding to issue
nim-lang/Nim#10807 changes received tree from
nkAddr(subDocsId) to nkCall(addr(subDocsId)).  Accept either old or new tree.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.