Skip to content

Compiler generates incorrect tempsMap for certain combinations of nested blocks and conditional jumps #304

@daniels220

Description

@daniels220

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions