Skip to content

Commit

Permalink
fixes nim-lang#14917; Static seqs are turned into static arrays when …
Browse files Browse the repository at this point in the history
…passed through template.
  • Loading branch information
Pylgos committed Sep 2, 2023
1 parent bd6adbc commit 7c768c3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7c768c3

Please sign in to comment.