Noticed this due to a "upgrade" system transforming entities into new ones, so it'd delete X entities and create X entities, but only X - 1 would be remembered.
For the test case, what would happen is that you'd observe the sequence:
Create 0
Create 1
Kill 0
Kill 1
Create 2
Create 2
This is due to return i == max_id in the first post-kill create, and then returning max_id in the second call. It also seems to me like max_id is more clearly next_id -- if you disagree I can drop that commit, but that realization helped diagnose this bug.
Noticed this due to a "upgrade" system transforming entities into new ones, so it'd delete X entities and create X entities, but only X - 1 would be remembered.
For the test case, what would happen is that you'd observe the sequence:
This is due to return
i == max_id
in the first post-kill create, and then returningmax_id
in the second call. It also seems to me likemax_id
is more clearlynext_id
-- if you disagree I can drop that commit, but that realization helped diagnose this bug.