Skip to content

Instantly share code, notes, and snippets.

@flaviut
Last active Aug 29, 2015
Embed
What would you like to do?
type
TTest* = object
pos*: range[0..15]
proc next(state: var TTest): int64 =
assert(state.pos >= 0 and state.pos < 16, "pos is " & $state.pos)
# Error: unhandled exception: state.pos >= 0 and state.pos < 16 pos is 140736480769200 [EAssertionFailed]
# 140736480769200 is incremented by a few million each execution
state.pos = (state.pos + 1) and 15
var state = TTest()
var accm: int64 = 0
for i in 1..100000000:
accm = (next state)
# discard (next state) works without issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment