This commit is contained in:
Yuriy Glukhov 2018-06-15 14:06:52 +03:00 committed by zah
parent 3435dc1155
commit 42c8e730de
2 changed files with 7 additions and 1 deletions

View File

@ -18,7 +18,7 @@ proc toImmutableRange[T](a: seq[T]): Range[T] =
if a.len != 0:
when rangesGCHoldEnabled:
result.gcHold = a
result.start = unsafeAddr a[0]
result.start = addr result.gcHold[0]
result.mLen = int32(a.len)
when unsafeAPIEnabled:

View File

@ -63,3 +63,9 @@ suite "Typed ranges":
check n == @[A, B, C ,D]
check n != @[A, B, C ,C]
test "shallowness":
var s = @[1, 2, 3]
var r = s.toRange()
var r2 = r
check(r.baseAddr == r2.baseAddr)
# check(r.baseAddr == addr s[0]) # XXX: Uncomment once nim bug #8044 is fixed