close #8829(add testcase for #8829) (#15866)

(cherry picked from commit fb60e35a54)
This commit is contained in:
flywind
2020-11-06 23:39:20 +08:00
committed by narimiran
parent 839ec1395d
commit e7d14ce6f2

18
tests/overload/t8829.nim Normal file
View File

@@ -0,0 +1,18 @@
block:
let txt = "Hello World"
template `[]`[T](p: ptr T, span: Slice[int]): untyped =
toOpenArray(cast[ptr array[0, T]](p)[], span.a, span.b)
doAssert $cast[ptr uint8](txt[0].unsafeAddr)[0 ..< txt.len] ==
"[72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]"
block:
let txt = "Hello World"
template `[]`[T](p: ptr T, span: Slice[int]): untyped =
toOpenArray(cast[ptr array[0, T]](p)[], span.a, span.b)
doAssert $cast[ptr uint8](txt[0].unsafeAddr)[0 ..< txt.len] ==
"[72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]"