From 42c8e730dee4c8eca58e77f4f48523129d3703c0 Mon Sep 17 00:00:00 2001 From: Yuriy Glukhov Date: Fri, 15 Jun 2018 14:06:52 +0300 Subject: [PATCH] Fixes #10 --- ranges/typedranges.nim | 2 +- tests/ttypedranges.nim | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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