Skip to content

Commit

Permalink
fixes #24630; static openArray backed by seq cannot be passed to anot…
Browse files Browse the repository at this point in the history
…her function
  • Loading branch information
ringabout committed Jan 22, 2025
1 parent 793baf3 commit 76998b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/vmgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2040,7 +2040,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)
Expand Down
9 changes: 9 additions & 0 deletions tests/vm/topenarrays.nim
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,12 @@ block: # bug #22095
z = fn()

doAssert z.limbs[0] == 10

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])

0 comments on commit 76998b2

Please sign in to comment.