Commit 00cf74e
for-of on a non-iterable, non-arraylike should throw an error.
The utility JS code used when transpiling a for-of loop down to ES5
checks for the `Symbol.iterator` property first, then falls back to
iterating as if the thing to be iterated is an array-like-thing.
This can end up hiding a `TypedError` that should have been thrown.
Check to make sure the thing to iterate over has a `length` property
before just treating it like an array when transpiling a for-of loop.
If it doesn't, throw a `TypeError`.
PiperOrigin-RevId: 5099693281 parent 3241a65 commit 00cf74e
File tree
4 files changed
+305
-196
lines changed- src/com/google/javascript/jscomp
- js
- es6/util
- resources
- test/com/google/javascript/jscomp/runtime_tests
4 files changed
+305
-196
lines changedLines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
37 | 42 | | |
0 commit comments