diff --git a/compiler/magicsys.nim b/compiler/magicsys.nim index 47a71d56cd..57b6a001ef 100644 --- a/compiler/magicsys.nim +++ b/compiler/magicsys.nim @@ -166,4 +166,4 @@ proc makeAddr*(n: PNode; idgen: IdGenerator): PNode = result = n else: result = newTree(nkHiddenAddr, n) - result.typ() = makePtrType(n.typ, idgen) + result.typ() = makePtrType(n.typ.skipTypes({tySink}), idgen) diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim index b42e6e26ec..0b71783575 100644 --- a/compiler/semmagic.nim +++ b/compiler/semmagic.nim @@ -38,7 +38,7 @@ proc semAddr(c: PContext; n: PNode): PNode = if isAssignable(c, x) notin {arLValue, arLocalLValue, arAddressableConst, arLentValue}: localError(c.config, n.info, errExprHasNoAddress) result.add x - result.typ() = makePtrType(c, x.typ) + result.typ() = makePtrType(c, x.typ.skipTypes({tySink})) proc semTypeOf(c: PContext; n: PNode): PNode = var m = BiggestInt 1 # typeOfIter diff --git a/tests/destructor/tsink.nim b/tests/destructor/tsink.nim index e8750ad7cc..754c737916 100644 --- a/tests/destructor/tsink.nim +++ b/tests/destructor/tsink.nim @@ -68,3 +68,11 @@ block: # bug #24175 static: foo() foo() + +proc create(value: sink int): ptr int = + let s = addr value + result = addr value + result = s + + +let xxx = create(12) \ No newline at end of file