• 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
..
OWNERS Loading commit data...
expression-scope.h Loading commit data...
func-name-inferrer.cc Loading commit data...
func-name-inferrer.h Loading commit data...
keywords-gen.h Loading commit data...
keywords.txt Loading commit data...
literal-buffer.cc Loading commit data...
literal-buffer.h Loading commit data...
parse-info.cc Loading commit data...
parse-info.h Loading commit data...
parser-base.h Loading commit data...
parser.cc Loading commit data...
parser.h Loading commit data...
parsing.cc Loading commit data...
parsing.h Loading commit data...
pending-compilation-error-handler.cc Loading commit data...
pending-compilation-error-handler.h Loading commit data...
preparse-data-impl.h Loading commit data...
preparse-data.cc Loading commit data...
preparse-data.h Loading commit data...
preparser-logger.h Loading commit data...
preparser.cc Loading commit data...
preparser.h Loading commit data...
rewriter.cc Loading commit data...
rewriter.h Loading commit data...
scanner-character-streams.cc Loading commit data...
scanner-character-streams.h Loading commit data...
scanner-inl.h Loading commit data...
scanner.cc Loading commit data...
scanner.h Loading commit data...
token.cc Loading commit data...
token.h Loading commit data...