• Sathya Gunasekaran's avatar
    [callprinter] Correctly point to the incorrect spread arg · 1d0693e2
    Sathya Gunasekaran authored
    The source position is set to the function call (console.log) not the
    spread (..x), in the bytecode generator, as the spread operation is
    done as part of the CallWithSpread bytecode.
    
    The CallPrinter stops at the function call and doesn't look at the
    arguments as well (in CallPrinter::VisitCall) to see if the error is
    from an incorrect spread operation.
    
    
    With this patch, we pass some state to the CallPrinter in the
    CallWithSpread error case and check that in CallPrinter::VisitCall
    before returning.
    
    For the given source string:
    ```
    x = undefined;
    console.log(1, ...x);
    ```
    
    Previously, the error was -
    
    ```
    test.js:2: TypeError: console.log is not iterable (cannot read property Symbol(Symbol.iterator))
    console.log(1, ...x);
            ^
    TypeError: console.log is not iterable (cannot read property Symbol(Symbol.iterator))
        at test.js:2:9
    ```
    
    
    Now, the error is -
    
    ```
    _test.js:2: TypeError: x is not iterable (cannot read property undefined)
    console.log(1, ...x);
                      ^
    TypeError: x is not iterable (cannot read property undefined)
        at _test.js:2:9
    ```
    
    Bug: v8:10038
    Change-Id: I199de9997f1d949c6f9b7b4f41d51f422b8b5131
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2037431Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
    Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
    Commit-Queue: Sathya Gunasekaran  <gsathya@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#66131}
    1d0693e2
Name
Last commit
Last update
..
benchmarks Loading commit data...
cctest Loading commit data...
common Loading commit data...
debugger Loading commit data...
fuzzer 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...