new now able to make distinction between ref and non-ref types, so we don't get 'ref ref' type when calling new on ref type

This commit is contained in:
krolik
2015-05-12 12:45:34 +03:00
parent 0b184f2584
commit 373717968e

View File

@@ -172,10 +172,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.