• 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
Name
Last commit
Last update
..
benchmarks Loading commit data...
cctest Loading commit data...
common Loading commit data...
debugger Loading commit data...
debugging Loading commit data...
fuzzer Loading commit data...
fuzzilli Loading commit data...
inspector Loading commit data...
intl Loading commit data...
js-perf-test Loading commit data...
memory Loading commit data...
message Loading commit data...
mjsunit Loading commit data...
mkgrokdump Loading commit data...
mozilla Loading commit data...
test262 Loading commit data...
torque Loading commit data...
unittests Loading commit data...
wasm-api-tests Loading commit data...
wasm-js Loading commit data...
wasm-spec-tests Loading commit data...
webkit Loading commit data...
BUILD.gn Loading commit data...
OWNERS Loading commit data...