for-in loops should always close iterator object



10 years ago
10 years ago


(Reporter: Jeff Thompson, Unassigned)


SeaMonkey 1.1 Branch
Windows Vista

Firefox Tracking Flags

(Not tracked)



(1 attachment)



10 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Gecko/20080702 SeaMonkey/1.1.11
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Gecko/20080702 SeaMonkey/1.1.11

This is very similar to bug 349326
which has been fixed in Gecko 1.9.0 / Firefox 3 for almost a year, but
I don't understand why the fix hasn't made it into Seamonkey.
When using an iterator function in a for each loop, breaking out of
the loop does not close the iterator, but it should

Reproducible: Always

Steps to Reproduce:
1.  Enter the following into a .html file (also attached):
<script type="text/javascript;version=1.7">
var x1 = 0;
function setX() {
  x1 = 1;
  try {
    yield true;
  finally {
    x1 = 0;

function test1() {
  for each (var f in setX()) {
    yield true;
  if (x1 == 0)
    alert("Success: finally was called");
    alert("Error: finally was not called");

for each (var f in test1()) {


2. Open the .html file in Seamonkey

Actual Results:  
Prints "Error: finally was not called"

Expected Results:  
Prints "Success: finally was called"

The break from the for each loop should close the iterator created by setX() whose finally clause should set x1 = 0.  This was argued at length in bug 349326

Comment 1

10 years ago
Created attachment 331905 [details]
The .html file in "steps to reproduce"
The version of SeaMonkey parallel with Firefox 3 is not Sm 1.1.x but Sm 2.0a1pre. (Sm 1.1 is parallel with Firefox 2, Sm 1.0 is parallel with Fx 1.5).

- does it work in SeaMonkey 2.0a1pre?
- does it work in Firefox 2 (or BonEcho)?

If the answers are respectively yes and no, then I suppose this bug is WONTFIX.

Comment 3

10 years ago
Just now confirmed fixed in Seamonkey 2.0a1pre.  Indeed, the bug is present in Firefox 2 but fixed in Firefox 3.  (I didn't know about Seamonkey 2.0a1pre).  

I changed the resolution to WONTFIX.
Last Resolved: 10 years ago
Resolution: --- → WONTFIX
WONTFIX applies (unless the higher-ups unset it) to Sm 1.1.x so I'm changing the Version to point to that branch (to which the current "official" release belongs).

For Sm 2 (which is officially "not yet at the alpha stage", so don't use it for mission-critical jobs and please report any bugs you find in it) it would be WORKSFORME, of course.
Version: unspecified → SeaMonkey 1.1 Branch
You need to log in before you can comment on or make changes to this bug.