From 7c768c383ef9f370f9aa5900426870c295b25789 Mon Sep 17 00:00:00 2001 From: Pylgos <43234674+Pylgos@users.noreply.github.com> Date: Sat, 2 Sep 2023 20:42:04 +0900 Subject: [PATCH] fixes #14917; Static seqs are turned into static arrays when passed through template. --- compiler/semexprs.nim | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index e9f90dcc05d31..67117654f5e08 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -643,6 +643,15 @@ proc arrayConstrType(c: PContext, n: PNode): PType = result = typ proc semArrayConstr(c: PContext, n: PNode, flags: TExprFlags; expectedType: PType = nil): PNode = + if n.typ != nil and n.typ.kind == tySequence: + if n.len == 0: return n + let arrToSeqSym = getSysMagic(c.graph, n.info, "@", mArrToSeq) + let arr = newNodeI(nkBracket, n.info) + for c in n: + arr.add c + let seqConstr = newTreeI(nkCall, n.info, newSymNode(arrToSeqSym, n.info), arr) + return semExprWithType(c, seqConstr, flags, expectedType) + result = newNodeI(nkBracket, n.info) result.typ = newTypeS(tyArray, c) var expectedElementType, expectedIndexType: PType = nil