diff options
author | flywind <43030857+xflywind@users.noreply.github.com> | 2020-11-06 23:39:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-06 23:39:20 +0800 |
commit | fb60e35a5495c530f8cf5c7a8cc3005495d089f8 (patch) | |
tree | c37f5262365f2254909b8c3aa43c5b0b3d2650ce /tests | |
parent | 9fd67958b97c0254c3b4d8762a7003e317ec21bb (diff) | |
download | Nim-fb60e35a5495c530f8cf5c7a8cc3005495d089f8.tar.gz |
close #8829(add testcase for #8829) (#15866)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/overload/t8829.nim | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/overload/t8829.nim b/tests/overload/t8829.nim new file mode 100644 index 000000000..a688e18cb --- /dev/null +++ b/tests/overload/t8829.nim @@ -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]" |