From 1b3725e3954ca01e5f37e82845549bdcce7d3901 Mon Sep 17 00:00:00 2001 From: c-blake Date: Fri, 12 Oct 2018 11:40:07 -0400 Subject: Add `toOpenArray[T](ptr UncheckedArray[T])` for clarity. (#9316) * Add `toOpenArray[T](ptr UncheckedArray[T])` for clarity. `ptr array[0,T]` for some unchecked type already works but A) `UncheckedArray` seems to be the intended future way for this kind of access, and B) essentially all use cases will have a `ptr` for that kind of array source and this call signature lets callers drop the trailing `[]` corresponding to that `ptr` deref. This PR relates to issue https://github.com/nim-lang/Nim/issues/9001 . * Add a test for toOpenArray() for UncheckedArray[T]s. --- compiler/ccgcalls.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'compiler') diff --git a/compiler/ccgcalls.nim b/compiler/ccgcalls.nim index 33b07a5a7..b23cd598e 100644 --- a/compiler/ccgcalls.nim +++ b/compiler/ccgcalls.nim @@ -106,7 +106,7 @@ proc openArrayLoc(p: BProc, n: PNode): Rope = result = "($1)+($2), ($3)-($2)+1" % [rdLoc(a), rdLoc(b), rdLoc(c)] else: result = "($1)+(($2)-($4)), ($3)-($2)+1" % [rdLoc(a), rdLoc(b), rdLoc(c), intLiteral(first)] - of tyOpenArray, tyVarargs: + of tyOpenArray, tyVarargs, tyUncheckedArray: result = "($1)+($2), ($3)-($2)+1" % [rdLoc(a), rdLoc(b), rdLoc(c)] of tyString, tySequence: if skipTypes(n.typ, abstractInst).kind == tyVar and -- cgit 1.4.1-2-gfad0