Merge

Tue, 12 Nov 2013 10:23:42 +0530

author
sundar
date
Tue, 12 Nov 2013 10:23:42 +0530
changeset 672
2f0f8d1d0753
parent 670
d091499d67fc
parent 671
e65a98146b94
child 673
1db3d4e4d189
child 676
779e155419b8

Merge

     1.1 --- a/src/jdk/nashorn/internal/codegen/Attr.java	Fri Nov 08 17:39:39 2013 -0800
     1.2 +++ b/src/jdk/nashorn/internal/codegen/Attr.java	Tue Nov 12 10:23:42 2013 +0530
     1.3 @@ -1265,12 +1265,17 @@
     1.4  
     1.5      @Override
     1.6      public Node leaveCOMMARIGHT(final BinaryNode binaryNode) {
     1.7 -        return end(ensureSymbol(binaryNode.rhs().getType(), binaryNode));
     1.8 +        return leaveComma(binaryNode, binaryNode.rhs());
     1.9      }
    1.10  
    1.11      @Override
    1.12      public Node leaveCOMMALEFT(final BinaryNode binaryNode) {
    1.13 -        return end(ensureSymbol(binaryNode.lhs().getType(), binaryNode));
    1.14 +        return leaveComma(binaryNode, binaryNode.lhs());
    1.15 +    }
    1.16 +
    1.17 +    private Node leaveComma(final BinaryNode commaNode, final Expression effectiveExpr) {
    1.18 +        ensureTypeNotUnknown(effectiveExpr);
    1.19 +        return end(ensureSymbol(effectiveExpr.getType(), commaNode));
    1.20      }
    1.21  
    1.22      @Override
     2.1 --- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Fri Nov 08 17:39:39 2013 -0800
     2.2 +++ b/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Tue Nov 12 10:23:42 2013 +0530
     2.3 @@ -412,6 +412,8 @@
     2.4              return method;
     2.5          }
     2.6  
     2.7 +        assert !type.isUnknown();
     2.8 +
     2.9          /*
    2.10           * The load may be of type IdentNode, e.g. "x", AccessNode, e.g. "x.y"
    2.11           * or IndexNode e.g. "x[y]". Both AccessNodes and IndexNodes are
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/script/basic/JDK-8028020.js	Tue Nov 12 10:23:42 2013 +0530
     3.3 @@ -0,0 +1,40 @@
     3.4 +/*
     3.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + * 
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.
    3.11 + * 
    3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.15 + * version 2 for more details (a copy is included in the LICENSE file that
    3.16 + * accompanied this code).
    3.17 + * 
    3.18 + * You should have received a copy of the GNU General Public License version
    3.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.21 + * 
    3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.23 + * or visit www.oracle.com if you need additional information or have any
    3.24 + * questions.
    3.25 + */
    3.26 +
    3.27 +/**
    3.28 + * JDK-8028020: Function parameter as last expression in comma in return value causes bad type calculation
    3.29 + *
    3.30 + * @test
    3.31 + * @run
    3.32 + */
    3.33 +
    3.34 +function f(x) {
    3.35 +    return 1, x
    3.36 +}
    3.37 +
    3.38 +function g(x, y) {
    3.39 +    return x, y
    3.40 +}
    3.41 +
    3.42 +print(f("'1, x' works."))
    3.43 +print(g(42, "'x, y' works too."))
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/script/basic/JDK-8028020.js.EXPECTED	Tue Nov 12 10:23:42 2013 +0530
     4.3 @@ -0,0 +1,2 @@
     4.4 +'1, x' works.
     4.5 +'x, y' works too.

mercurial