Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8059835

Optimistic splitting doesn't work with let and const

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 10
    • None
    • core-libs
    • None
    • b34
    • generic
    • generic

      Optimistic splitter works by replacing split nodes with anonymous function invocations. Part of this is moving all "var" statements out of nested functions into the outermost function. However, "let" and "const" are block scoped, and can't be moved without affecting the semantics of the program. They can't even be moved to the top of their block (as determination of temporal dead zone for them depends on the exact location of the occurrence of the "let"/"const" statement).

      This means that the splitter needs to be modified so as to treat every let/const as a splitting boundary. A block that is being split and has a let/const in it can't have said let/const engulfed by a split node; rather, split nodes must end before let/const and then a new split node must start after let/const.

      Note that with this approach, the optimistic splitter will work; the change needs to be made in the Splitter, not in the SplitIntoFunctions transformer.

            hannesw Hannes Wallnoefer
            attila Attila Szegedi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: