js/src/tests/js1_8_5/extensions/regress-627859.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_8_5/extensions/regress-627859.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,23 @@
     1.4 +// -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 +// Any copyright is dedicated to the Public Domain.
     1.6 +// http://creativecommons.org/licenses/publicdomain/
     1.7 +
     1.8 +var x = 42;
     1.9 +function a() { 
    1.10 +    var x;
    1.11 +    function b() {
    1.12 +        x = 43;
    1.13 +        // When jsparse.cpp's CompExprTransplanter transplants the
    1.14 +        // comprehension expression 'x' into the scope of the 'for' loop,
    1.15 +        // it must not bring the placeholder definition node for the
    1.16 +        // assignment to x above along with it. If it does, x won't appear
    1.17 +        // in b's lexdeps, we'll never find out that the assignment refers
    1.18 +        // to a's x, and we'll generate an assignment to the global x.
    1.19 +        (x for (x in []));
    1.20 +    }
    1.21 +    b();
    1.22 +}
    1.23 +a();
    1.24 +assertEq(x, 42);
    1.25 +
    1.26 +reportCompare(true, true);

mercurial