diff --git a/ranges/typedranges.nim b/ranges/typedranges.nim index 4d2eb7c..c879b30 100644 --- a/ranges/typedranges.nim +++ b/ranges/typedranges.nim @@ -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: diff --git a/tests/ttypedranges.nim b/tests/ttypedranges.nim index ec41609..50ec8ff 100644 --- a/tests/ttypedranges.nim +++ b/tests/ttypedranges.nim @@ -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