summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2022-10-21 13:38:40 +0800
committerGitHub <noreply@github.com>2022-10-21 13:38:40 +0800
commit1db25ffcd3ae4fefdfe6f52f8a6f17f9efa21048 (patch)
treeb690aadc6a5f5caacc00c3c59b64d4d932073228
parent76763f51aa119e71b00200142292acf5f1fdc69c (diff)
downloadNim-1db25ffcd3ae4fefdfe6f52f8a6f17f9efa21048.tar.gz
closes #19969; add testcase for #19969 #15952 #16306 (#20610)
closes #19969; add testcase
-rw-r--r--tests/vm/topenarrays.nim27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/vm/topenarrays.nim b/tests/vm/topenarrays.nim
index 4e3bef480..639e0c35b 100644
--- a/tests/vm/topenarrays.nim
+++ b/tests/vm/topenarrays.nim
@@ -35,4 +35,31 @@ static:
   assert arr.toOpenArray(3, 4).toOpenArray(0, 0) == [1]
 
 
+# bug #19969
+proc f(): array[1, byte] =
+  var a: array[1, byte]
+  result[0..0] = a.toOpenArray(0, 0)
 
+doAssert static(f()) == [byte(0)]
+
+
+# bug #15952
+proc main1[T](a: openArray[T]) = discard
+proc main2[T](a: var openArray[T]) = discard
+
+proc main =
+  var a = [1,2,3,4,5]
+  main1(a.toOpenArray(1,3))
+  main2(a.toOpenArray(1,3))
+static: main()
+main()
+
+# bug #16306
+{.experimental: "views".}
+proc test(x: openArray[int]): tuple[id: int] =
+  let y: openArray[int] = toOpenArray(x, 0, 2)
+  result = (y[0],)
+template fn=
+  doAssert test([0,1,2,3,4,5]).id == 0
+fn() # ok
+static: fn()