DescriptionFix priority of exceptions being thrown from for-of loops
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
Committed: https://crrev.com/5f67e34aed279d3239f66f8fb0a26e650ec7bb79
Cr-Commit-Position: refs/heads/master@{#34261}
Patch Set 1 #Patch Set 2 : Fix iterator-close tests and holding onto value #Patch Set 3 : Fix formatting #Patch Set 4 : Rebase, with test262 expectations updated #
Messages
Total messages: 18 (9 generated)
|