This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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