for-in loops should always close iterator object

RESOLVED WONTFIX

Status

SeaMonkey
General
RESOLVED WONTFIX
10 years ago
10 years ago

People

(Reporter: Jeff Thompson, Unassigned)

Tracking

SeaMonkey 1.1 Branch
x86
Windows Vista

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

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

This is very similar to bug 349326
https://bugzilla.mozilla.org/show_bug.cgi?id=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):
<html>
<head>
<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;
    break;
  }
  if (x1 == 0)
    alert("Success: finally was called");
  else
    alert("Error: finally was not called");
}

for each (var f in test1()) {
}

</script>
</head>
</html>

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
https://bugzilla.mozilla.org/show_bug.cgi?id=349326
(Reporter)

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).

So:
- does it work in SeaMonkey 2.0a1pre?
    http://ftp.mozilla.org/pub/mozilla.org/seamonkey/nightly/latest-trunk/
- does it work in Firefox 2 (or BonEcho)?
    http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-mozilla1.8/

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

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.
Status: UNCONFIRMED → RESOLVED
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.