• Sathya Gunasekaran's avatar
    [ast] Store correct source position on ThisExpression · 8a9e3f64
    Sathya Gunasekaran authored
    Previously, all ThisExpression's had kNoSourcePositions leading to
    incorrect error messages like this:
    
      ➜ d8 -e "function t() { for (const x of this) {} } t();"
      unnamed:1: TypeError: undefined is not a function
      function t() { for (const x of this) {} } t();
                ^
      TypeError: undefined is not a function
          at t (unnamed:1:11)
          at unnamed:1:43
    
    
    This patch allows creation of a ThisExpression with a source position,
    leading to a better error message:
    
      ➜ d8  -e "function t() { for (const x of this) {} } t();"
      unnamed:1: TypeError: this is not iterable
      function t() { for (const x of this) {} } t();
                                     ^
      TypeError: this is not iterable
          at t (unnamed:1:32)
          at unnamed:1:43
    
    
    This patch does not remove the existing cached version of
    ThisExpression and instead creates a new one when required.
    
    Bug: v8:6513
    Change-Id: Idee4fe8946a9b821d06ff4a5e7eaefe54874ec59
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2345226Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
    Commit-Queue: Sathya Gunasekaran  <gsathya@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#69300}
    8a9e3f64
this-iterator-undefined.out 347 Bytes