-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
I encountered a strange error where the inner scope reference to a table becomes all zeros under very specific conditions.
I am not sure I can explain it better than the POC below:
import tables
var table* = initTable[int, int]()
# Must be this sequence...
for id in @[1, 2, 3, 4, 5, 6, 7, 8, 100, 101, 102, 200, 201, 202, 203, 204, 300, 301, 302, 303, 304, 305, 306, 308, 309, 310, 311, 312, 313, 314, 315, 316]:
table[id] = id
proc inner() =
for i in 0..11: # Must be larger than 10
table[-i] = i # Doesn't work without negating i
proc outer*(table2: Table[int, int]) =
inner()
assert table2.contains(1) # All values are zeroed in inner scope...
assert table.contains(1) # Works
outer(table)