-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
Description
Nim Version
Nim Compiler Version 2.2.6 [MacOSX: amd64]
Compiled at 2025-10-31
Copyright (c) 2006-2025 by Andreas Rumpf
active boot switches: -d:release
Description
The latest version (2.2.6) crashes when using iterators on temporary values returned from const Table lookups. My guess would be that this is a regression most likely introduced by the optimization to fix #24093.
Minimal example:
import tables, unicode, sequtils
const
myTable = {
"en": "abcdefghijklmnopqrstuvwxyz",
}.toTable
proc buggyVersion(locale: string): seq[Rune] =
result = toSeq(runes(myTable[locale]))
proc workingVersion(locale: string): seq[Rune] =
# string lifetime is extended
let str = myTable[locale]
result = toSeq(runes(str))
echo "Testing working version..."
let runes2 = workingVersion("en")
echo "Got ", runes2.len, " runes"
echo "Testing buggy version..."
let runes1 = buggyVersion("en") # <-- CRASHES HERE
echo "Got ", runes1.len, " runes"Current Output
Testing working version...
Got 26 runes
Testing buggy version...
Expected Output
Testing working version...
Got 26 runes
Testing buggy version...
Got 26 runes
Known Workarounds
No response
Additional Information
No response