mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-20 22:35:24 +00:00
@@ -15,7 +15,7 @@ const
|
||||
errXExpectsTypeOrValue = "'$1' expects a type or value"
|
||||
errVarForOutParamNeededX = "for a 'var' type a variable needs to be passed; but '$1' is immutable"
|
||||
errXStackEscape = "address of '$1' may not escape its stack frame"
|
||||
errExprHasNoAddress = "expression has no address; maybe use 'unsafeAddr'"
|
||||
errExprHasNoAddress = "expression has no address"
|
||||
errCannotInterpretNodeX = "cannot evaluate '$1'"
|
||||
errNamedExprExpected = "named expression expected"
|
||||
errNamedExprNotAllowed = "named expression not allowed here"
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
7
tests/errmsgs/t10594.nim
Normal file
7
tests/errmsgs/t10594.nim
Normal file
@@ -0,0 +1,7 @@
|
||||
discard """
|
||||
errormsg: "expression has no address"
|
||||
line: 7
|
||||
"""
|
||||
|
||||
template foo(v: varargs[int]) = unsafeAddr v
|
||||
foo(1, 2)
|
||||
Reference in New Issue
Block a user