Closed Bug 1326109 Opened 5 years ago Closed 5 years ago

for-of not call '.return()' on abrupt completion (break or return)

Categories

(Core :: JavaScript Engine, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1147371

People

(Reporter: ds.victor94, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36

Steps to reproduce:

evaluated that code:

const gen = function* () { let i=0; while(true) yield i++;}()
for (let id of gen){console.log(id); break;}
console.log(gen.next());


Actual results:

and output the result below

0 
Object { value: 1, done: false }


Expected results:

but as specified at ECMACScript 2016 Language Specification, on session 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation ( lhs, stmt, iterator, lhsKind, labelSet ) in item 5.k
<http://www.ecma-international.org/ecma-262/7.0/index.html#sec-runtime-semantics-forin-div-ofbodyevaluation-lhs-stmt-iterator-lhskind-labelset>

the result must be:

0 
Object { value: undefined, done: true }

because if loop not continuous, iterator mas be closed to clean up propose
OS: Unspecified → Linux
Hardware: Unspecified → x86_64
Is this a duplicate of bug 1147371, or some dependency of it?
(In reply to Jeff Walden [:Waldo] (remove +bmo to email) from comment #1)
> Is this a duplicate of bug 1147371, or some dependency of it?

It is.
Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1147371
You need to log in before you can comment on or make changes to this bug.