Debug the following:
| env |
env := 0.
#(#foo #bar #baz)
withIndexDo: [:argOuter :i | false ifFalse: [#(1 2 3 4 5) do: [:argInner | env := env + 1]]].
Step until env + 1 is selected. Step again at this point and you will hit an "index 2 is out of bounds" error in Debugger>>updateTemporaries. This appears to be caused by the inclusion of argOuter and i in the tempsMap at that point, when in fact they are unavailable.
Minor variations of this code exhibit the same problem—the necessary conditions appear to be as follows:
- The outer block must have at least two combined args and temps (one arg and one assigned-but-unused temp also causes the problem)
- The inner block must be inside an optimized conditional expression (#ifNil: also works)
- The inner block must make use of an env temp, though it need not assign to it (the outer loop can assign to it, causing it to be stored in the Context, while the inner loop only reads from it)