• Daniel Ehrenberg's avatar
    [scopes] Fix sloppy-mode block-scoped function hoisting edge case · d54ffadf
    Daniel Ehrenberg authored
    In edge cases such as the following, sloppy-mode block-scoped function
    hoisting is expected to occur:
    
      eval(`
        with({a: 1}) {
          function a() {}
        }
      `)
    
    In this case, there should be the equivalent of a var declaration
    outside of the eval, which gets set to the value of the local function
    a when the body of the with is executed.
    
    Previously, the way that var declarations are hoisted out of eval
    meant that the assignment to that var was an ordinary DYNAMIC_GLOBAL
    assignment. However, such a lookup mode meant that the object in the
    with scope received the assignment!
    
    This patch fixes that error by marking the assignments produced by
    the sloppy mode block scoped function hoisting desugaring so as to
    generate a different runtime call which skips with scopes.
    
    Bug: chromium:720247, v8:5135
    Change-Id: Ie36322ddc9ca848bf680163e8c016f50d4597748
    Reviewed-on: https://chromium-review.googlesource.com/529230
    Commit-Queue: Daniel Ehrenberg <littledan@chromium.org>
    Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
    Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
    Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#46116}
    d54ffadf