diff options
author | flywind <xzsflywind@gmail.com> | 2021-04-19 17:21:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-19 11:21:35 +0200 |
commit | 83fa0fc843a5757c6fa1af9ac89b85b71c0c7581 (patch) | |
tree | 5f7b4659f938dc1d5e63f34dfe169ec49fad60fd /tests | |
parent | dc89b212572fecd449dd469ffb2424c78941c12f (diff) | |
download | Nim-83fa0fc843a5757c6fa1af9ac89b85b71c0c7581.tar.gz |
fix #12521(type alias for openArray) (#17593)
* fix nim js cmp fails at CT * fix #12521 * address comments
Diffstat (limited to 'tests')
-rw-r--r-- | tests/openarray/topenarray.nim | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/openarray/topenarray.nim b/tests/openarray/topenarray.nim index 0b6e3afc4..aec5a4cbf 100644 --- a/tests/openarray/topenarray.nim +++ b/tests/openarray/topenarray.nim @@ -23,5 +23,31 @@ proc main = when defined(js): discard # xxx bug #15952: `a` left unchanged else: doAssert a == [1, 0, 10, 20, 5] + block: # bug #12521 + block: + type slice[T] = openArray[T] + + # Proc using that alias + proc testing(sl: slice[int]): seq[int] = + for item in sl: + result.add item + + let mySeq = @[1, 2, 3, 4, 5, 6, 7, 8, 9] + doAssert testing(mySeq) == mySeq + doAssert testing(mySeq[2..^2]) == mySeq[2..^2] + + block: + type slice = openArray[int] + + # Proc using that alias + proc testing(sl: slice): seq[int] = + for item in sl: + result.add item + + let mySeq = @[1, 2, 3, 4, 5, 6, 7, 8, 9] + doAssert testing(mySeq) == mySeq + doAssert testing(mySeq[2..^2]) == mySeq[2..^2] + + main() # static: main() # xxx bug #15952: Error: cannot generate code for: mSlice |