Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 495738

Summary: [es6] iterators + for..of parsing error
Product: [ECD] Orion Reporter: Muhammad Mousa <mmousa>
Component: JS ToolsAssignee: 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:

Description Muhammad Mousa CLA 2016-06-08 14:47:22 EDT
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);
}
Comment 1 Olivier Thomann CLA 2016-06-08 15:09:12 EDT
I will check what ast is returned by acorn.
Comment 2 Olivier Thomann CLA 2016-06-08 15:16:51 EDT
The tree is fine. The bug comes from the "semi" rule. Fix ix trivial.
Comment 3 Olivier Thomann CLA 2016-06-08 15:33:16 EDT
Delivered as commit fcbb1a00c156001022337234d49ffad5b0c96844