Stop useless suggestion of unsafeAddr (#10598)

Fixes #10594
This commit is contained in:
LemonBoy 2019-02-08 08:59:38 +01:00 • committed by Andreas Rumpf
commit 6b88ce3384
3 changed files with 14 additions and 2 deletions

View file

@ -16,7 +16,12 @@ proc semAddr(c: PContext; n: PNode; isUnsafeAddr=false): PNode =
if x.kind == nkSym:
x.sym.flags.incl(sfAddrTaken)
if isAssignable(c, x, isUnsafeAddr) notin {arLValue, arLocalLValue}:
localError(c.config, n.info, errExprHasNoAddress)
# Do not suggest the use of unsafeAddr if this expression already is a
# unsafeAddr
if isUnsafeAddr:
localError(c.config, n.info, errExprHasNoAddress)
else:
localError(c.config, n.info, errExprHasNoAddress & "; maybe use 'unsafeAddr'")
result.add x
result.typ = makePtrType(c, x.typ)