summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2022-12-04 15:39:14 +0800
committerGitHub <noreply@github.com>2022-12-04 15:39:14 +0800
commit55373e65b44c5d15ced134fb59ef24ccfbeee64c (patch)
tree15146b7e30fb681aee910e7b45fdb8a0bb14e667
parent83493e42949fb954c66961328dde50a32f916743 (diff)
downloadNim-55373e65b44c5d15ced134fb59ef24ccfbeee64c.tar.gz
unpublic `arrayWith` and rename it to `nimArrayWith` (#21006)
* unpublic arrayWith

* unindent
-rw-r--r--compiler/sem.nim8
-rw-r--r--lib/system.nim2
-rw-r--r--tests/objects/tobject_default_value.nim2
3 files changed, 6 insertions, 6 deletions
diff --git a/compiler/sem.nim b/compiler/sem.nim
index 25116f8d6..a1388bd87 100644
--- a/compiler/sem.nim
+++ b/compiler/sem.nim
@@ -642,10 +642,10 @@ proc defaultNodeField(c: PContext, a: PNode, aTyp: PType, id: var IntSet): PNode
     if child != nil:
       let node = newNode(nkIntLit)
       node.intVal = toInt64(lengthOrd(c.graph.config, aTypSkip))
-      result = semExpr(c, newTree(nkCall, newSymNode(getSysSym(c.graph, a.info, "arrayWith"), a.info),
-              semExprWithType(c, child),
-              node
-                ))
+      result = semExpr(c, newTree(nkCall, newSymNode(getCompilerProc(c.graph, "nimArrayWith"), a.info),
+        semExprWithType(c, child),
+        node
+          ))
       result.typ = aTyp
   elif aTypSkip.kind == tyTuple:
     var hasDefault = false
diff --git a/lib/system.nim b/lib/system.nim
index ac806759c..8faf8f4ce 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -2798,7 +2798,7 @@ when notJSnotNims and not defined(nimSeqsV2):
       assert y == "abcgh"
     discard
 
-proc arrayWith*[T](y: T, size: static int): array[size, T] {.noinit.} = # ? exempt from default value for result
+proc nimArrayWith[T](y: T, size: static int): array[size, T] {.compilerRtl, raises: [].} =
   ## Creates a new array filled with `y`.
   for i in 0..size-1:
     result[i] = y
diff --git a/tests/objects/tobject_default_value.nim b/tests/objects/tobject_default_value.nim
index 7ea4b42ae..cdc6016e0 100644
--- a/tests/objects/tobject_default_value.nim
+++ b/tests/objects/tobject_default_value.nim
@@ -267,7 +267,7 @@ template main {.dirty.} =
         doAssert $(@my) == """@['\x00', '\x00', '\x00', '\x00', '\x00']"""
 
   block: # array
-    var x: array[10, Object] = arrayWith(default(Object), 10)
+    var x: array[10, Object] = default(array[10, Object])
     let y = x[0]
     doAssert y.value == 12
     doAssert y.time == 1.2