• 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...
ast-function-literal-id-reindexer.cc Loading commit data...
ast-function-literal-id-reindexer.h Loading commit data...
ast-source-ranges.h Loading commit data...
ast-traversal-visitor.h Loading commit data...
ast-value-factory.cc Loading commit data...
ast-value-factory.h Loading commit data...
ast.cc Loading commit data...
ast.h Loading commit data...
modules.cc Loading commit data...
modules.h Loading commit data...
prettyprinter.cc Loading commit data...
prettyprinter.h Loading commit data...
scopes.cc Loading commit data...
scopes.h Loading commit data...
source-range-ast-visitor.cc Loading commit data...
source-range-ast-visitor.h Loading commit data...
variables.cc Loading commit data...
variables.h Loading commit data...