| Summary: | [es6] iterators + for..of parsing error | ||
|---|---|---|---|
| Product: | [ECD] Orion | Reporter: | Muhammad Mousa <mmousa> |
| Component: | JS Tools | Assignee: | Olivier Thomann <Olivier_Thomann> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | curtis.windatt.public, Michael_Rennie, Olivier_Thomann |
| Version: | 12.0 | ||
| Target Milestone: | 12.0 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
I will check what ast is returned by acorn. The tree is fine. The bug comes from the "semi" rule. Fix ix trivial. Delivered as commit fcbb1a00c156001022337234d49ffad5b0c96844 |
for (var n of iteratorObject) throws the warning: `Missing semicolon.` and attempts to add one after n, correcting it to for (var n; of iteratorObject) which is incorrect. This example (test in chrome browser) should print the first Fibonacci numbers under 20 (1, 2, 3, 5, 8, 13). It makes use of for..of and iterator objects. let fibonacci = { [Symbol.iterator]() { let pre = 0, cur = 1; return { next() { [pre, cur] = [cur, pre + cur]; return { done: false, value: cur } } } } } for (var n of fibonacci) { // truncate the sequence at 20 if (n > 20) break; console.log(n); }