• littledan's avatar
    Fix priority of exceptions being thrown from for-of loops · 5f67e34a
    littledan authored
    In the for-of desugaring, IteratorClose is a subtle thing to get right.
    When return exists, the logic for which exception to throw is as follows:
    1. Get the 'return' property and property any exception that might come from
      the property read
    2. Call return, not yet propagating an exception if it's thrown.
    3. If we are closing the iterator due to an exception, propagate that error.
    4. If return threw, propagate that error.
    5. Check if return's return value was not an object, and throw if so
    
    Previously, we were effectively doing step 5 even if an exception "had already
    been thrown" by step 3. Because this took place in a finally block, the exception
    "won the race" and was the one propagated to the user. The fix is a simple change
    to the desugaring to do step 5 only if step 3 didn't happen.
    
    R=rossberg
    BUG=v8:4775
    LOG=Y
    
    Review URL: https://codereview.chromium.org/1728973002
    
    Cr-Commit-Position: refs/heads/master@{#34261}
    5f67e34a
Name
Last commit
Last update
..
benchmarks Loading commit data...
cctest Loading commit data...
fuzzer 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...
mozilla Loading commit data...
preparser Loading commit data...
promises-aplus Loading commit data...
simdjs Loading commit data...
test262 Loading commit data...
unittests Loading commit data...
webkit Loading commit data...
bot_default.gyp Loading commit data...
bot_default.isolate Loading commit data...
default.gyp Loading commit data...
default.isolate Loading commit data...
ignition.gyp Loading commit data...
ignition.isolate Loading commit data...
optimize_for_size.gyp Loading commit data...
optimize_for_size.isolate Loading commit data...
perf.gyp Loading commit data...
perf.isolate Loading commit data...