Not a Bug

For Loop Index Out of Range.

Marshall Brooks 4 years ago updated by Lazlo Bonin (Lead Developer) 4 years ago 3

So in the Graph inspector, the for loop is described as having an index range of min (inclusive), to max (exclusive). However, just now I received an error showing an index range equal to the max value of the range.

I just threw in a branch with a logic test to make sure the index is below max, but I figured I should share this bug. Hopefully it's reproducible.

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):

Never mind, I'm an idiot. Please delete this thread! :)


Glad you got it sorted, but I've seen this come up before, so here's an explanation for those that come along later:

The Index port is kept at the last value when the Exit condition is followed.  This means you can still use the index in a test if you broke out of the loop early with Break.  In this case, however, the for loop reached the end of the loop and exits when the index has hit the last value.  This means that the Index port will be the Last value, even though it never traveled down the Body flow with that final 81.

0-80 : Body
81: Exit

Not a Bug

Actually never thought of that when implementing the for loop unit, but I feel like this is the "correct" behaviour? :P

Anyway, glad you got it sorted out!