-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
Nim Version
Nim Compiler Version 2.2.4 [MacOSX: arm64]
Compiled at 2025-12-29
Copyright (c) 2006-2025 by Andreas Rumpf
git hash: f7145dd
active boot switches: -d:release
Description
import std/algorithm
func doCompute(a: ptr UncheckedArray[int], len: int): seq[int] =
var foo = newSeq[int](len)
for i in 0 ..< len:
foo[i] = i
foo.sort do (x, y: auto) -> int:
cmp(a[x], a[y])
foo
func compute(a: openArray[int]): seq[int] =
doCompute(cast[ptr UncheckedArray[int]](unsafeAddr a[0]), a.len)
const x = [1, 2, 3]
static: echo compute(x) # Works without `static`Current Output
stack trace: (most recent call last)
/Users/etan/Documents/Repos/nimbus-eth2/test.nim(15, 21) test
/Users/etan/Documents/Repos/nimbus-eth2/test.nim(12, 13) compute
/Users/etan/Documents/Repos/nimbus-eth2/test.nim(12, 13) Error: opcCastIntToPtr: regs[rb].kind: rkNodeAddr
Expected Output
@[0, 1, 2]
Known Workarounds
Works at runtime
Additional Information
No response
Metadata
Metadata
Assignees
Labels
No labels