Merge pull request #2699 from SSPkrolik/newrefref

new now able to make distinction between ref and non-ref types, so we…
This commit is contained in:
Andreas Rumpf 2015-08-02 11:05:47 +02:00
commit 6fea1a7bb6

View file

@ -176,10 +176,16 @@ proc new*[T](a: var ref T) {.magic: "New", noSideEffect.}
## creates a new object of type ``T`` and returns a safe (traced)
## reference to it in ``a``.
proc new*(T: typedesc): ref T =
proc new*(T: typedesc): auto =
## creates a new object of type ``T`` and returns a safe (traced)
## reference to it as result value
new(result)
when (T is ref):
var r: T
else:
var r: ref T
new(r)
return r
proc internalNew*[T](a: var ref T) {.magic: "New", noSideEffect.}
## leaked implementation detail. Do not use.