summary refs log tree commit diff stats
path: root/tests/arc
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-07-05 17:21:57 +0800
committerGitHub <noreply@github.com>2023-07-05 11:21:57 +0200
commit145e002c74c4393b9ac71d5a8cfe066fbf38a048 (patch)
tree0077de57d031b4edf09938d052a68e37029db6e3 /tests/arc
parent86ff37fab8656f7acd08fc9c3fa237f9e022dbf4 (diff)
downloadNim-145e002c74c4393b9ac71d5a8cfe066fbf38a048.tar.gz
fixes #22132; hoisted openArray params result in erroneous code (#22224)
Diffstat (limited to 'tests/arc')
-rw-r--r--tests/arc/topenarray.nim18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/arc/topenarray.nim b/tests/arc/topenarray.nim
index 0e45f3ec7..67c512e4f 100644
--- a/tests/arc/topenarray.nim
+++ b/tests/arc/topenarray.nim
@@ -50,3 +50,21 @@ proc f(a: var string) =
 var a = "Hello"
 f(a)
 doAssert a == "Hallo"
+
+# bug #22132
+block:
+  func foo[T](arr: openArray[T], idx: int = arr.low): string =
+    doAssert idx == 0
+    return $arr
+
+  let bug = ["0", "c", "a"]
+
+  let str = foo(bug)
+
+  const expected = """["0", "c", "a"]"""
+  doAssert str == expected
+
+  const noBugConst = ["0", "c", "a"]
+  doAssert foo(noBugConst) == expected
+  let noBugSeq = @["0", "c", "a"]
+  doAssert foo(noBugSeq) == expected