And a patch...

Christophe Grand a écrit :
I filed a bug, see https://bugzilla.mozilla.org/show_bug.cgi?id=407374

Steps to Reproduce:
function f(a, [b]) {
    java.lang.Thread.sleep(2000);
    print(a + ";" + b);
}
spawn(f, [1, [2]]);
spawn(f, [3, [4]]);
Actual Results:
3;4
1;4

Expected Results:
3;4
1;2

Christophe

Christophe Grand a écrit :
I report it while it's hot (and I haven't got time to come up with a test yet).

I have a function with destructured parameters
(eg function(a, [b]) {...}).

This function is called from several threads and the b (in this example) appears to be shared :-( If I rewrite my functions without destructured parameters (eg function(a, ab) { const b = ab[0]; ... } it solves the problem.

(Rhino CVS Mode running in compile mode)

Christophe

Index: src/org/mozilla/javascript/Parser.java
===================================================================
RCS file: /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/Parser.java,v
retrieving revision 1.122
diff -u -r1.122 Parser.java
--- src/org/mozilla/javascript/Parser.java      28 Sep 2007 15:37:04 -0000      
1.122
+++ src/org/mozilla/javascript/Parser.java      8 Dec 2007 20:51:45 -0000
@@ -572,9 +572,9 @@
                         }
                         String parmName = currentScriptOrFn.getNextTempName();
                         defineSymbol(Token.LP, parmName);
-                        destructuring.addChildToBack(nf.createAssignment(
-                            Token.ASSIGN, primaryExpr(), 
-                            nf.createName(parmName)));
+                        destructuring.addChildToBack(
+                                       
nf.createDestructuringAssignment(Token.VAR,
+                                                       primaryExpr(), 
nf.createName(parmName)));
                     } else {
                         mustMatchToken(Token.NAME, "msg.no.parm");
                         String s = ts.getString();
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to