unpublic arrayWith and rename it to nimArrayWith (#21006)
* unpublic arrayWith * unindent
This commit is contained in:
parent
83493e4294
commit
55373e65b4
3 changed files with 6 additions and 6 deletions
|
|
@ -642,10 +642,10 @@ proc defaultNodeField(c: PContext, a: PNode, aTyp: PType, id: var IntSet): PNode
|
||||||
if child != nil:
|
if child != nil:
|
||||||
let node = newNode(nkIntLit)
|
let node = newNode(nkIntLit)
|
||||||
node.intVal = toInt64(lengthOrd(c.graph.config, aTypSkip))
|
node.intVal = toInt64(lengthOrd(c.graph.config, aTypSkip))
|
||||||
result = semExpr(c, newTree(nkCall, newSymNode(getSysSym(c.graph, a.info, "arrayWith"), a.info),
|
result = semExpr(c, newTree(nkCall, newSymNode(getCompilerProc(c.graph, "nimArrayWith"), a.info),
|
||||||
semExprWithType(c, child),
|
semExprWithType(c, child),
|
||||||
node
|
node
|
||||||
))
|
))
|
||||||
result.typ = aTyp
|
result.typ = aTyp
|
||||||
elif aTypSkip.kind == tyTuple:
|
elif aTypSkip.kind == tyTuple:
|
||||||
var hasDefault = false
|
var hasDefault = false
|
||||||
|
|
|
||||||
|
|
@ -2798,7 +2798,7 @@ when notJSnotNims and not defined(nimSeqsV2):
|
||||||
assert y == "abcgh"
|
assert y == "abcgh"
|
||||||
discard
|
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`.
|
## Creates a new array filled with `y`.
|
||||||
for i in 0..size-1:
|
for i in 0..size-1:
|
||||||
result[i] = y
|
result[i] = y
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,7 @@ template main {.dirty.} =
|
||||||
doAssert $(@my) == """@['\x00', '\x00', '\x00', '\x00', '\x00']"""
|
doAssert $(@my) == """@['\x00', '\x00', '\x00', '\x00', '\x00']"""
|
||||||
|
|
||||||
block: # array
|
block: # array
|
||||||
var x: array[10, Object] = arrayWith(default(Object), 10)
|
var x: array[10, Object] = default(array[10, Object])
|
||||||
let y = x[0]
|
let y = x[0]
|
||||||
doAssert y.value == 12
|
doAssert y.value == 12
|
||||||
doAssert y.time == 1.2
|
doAssert y.time == 1.2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue