fixes #24630; static openArray backed by seq cannot be passed to another function (#24638)

fixes #24630

(cherry picked from commit 2f402fcb82)
This commit is contained in:
ringabout
2025-01-22 21:05:57 +08:00
committed by narimiran
parent 772ebe6715
commit e2ae7d5f43
2 changed files with 10 additions and 1 deletions

View File

@@ -2013,7 +2013,7 @@ proc genArrayConstr(c: PCtx, n: PNode, dest: var TDest) =
c.gABx(n, opcLdNull, dest, c.genType(n.typ))
let intType = getSysType(c.graph, n.info, tyInt)
let seqType = n.typ.skipTypes(abstractVar-{tyTypeDesc})
let seqType = n.typ.skipTypes(abstractVar+{tyStatic}-{tyTypeDesc})
if seqType.kind == tySequence:
var tmp = c.getTemp(intType)
c.gABx(n, opcLdImmInt, tmp, n.len)

View File

@@ -67,3 +67,12 @@ template fn=
doAssert test([0,1,2,3,4,5]).id == 0
fn() # ok
static: fn()
block: # bug #24630
func f(a: static openArray[int]): int =
12
func g(a: static openArray[int]) =
const b = f(a)
g(@[1,2,3])