Merge

Tue, 02 Jul 2013 15:01:38 +0200

author
lagergren
date
Tue, 02 Jul 2013 15:01:38 +0200
changeset 396
69ec02d12a31
parent 395
9396e42bae4f
parent 394
74049fe3ba46
child 397
16c4535abcf8
child 401
313bdcd2fd22

Merge

     1.1 --- a/src/jdk/nashorn/internal/parser/Parser.java	Tue Jul 02 14:50:39 2013 +0200
     1.2 +++ b/src/jdk/nashorn/internal/parser/Parser.java	Tue Jul 02 15:01:38 2013 +0200
     1.3 @@ -535,15 +535,12 @@
     1.4              if (!(lhs instanceof AccessNode ||
     1.5                    lhs instanceof IndexNode ||
     1.6                    lhs instanceof IdentNode)) {
     1.7 -                if (env._early_lvalue_error) {
     1.8 -                    throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken());
     1.9 -                }
    1.10 -                return referenceError(lhs, rhs);
    1.11 +                return referenceError(lhs, rhs, env._early_lvalue_error);
    1.12              }
    1.13  
    1.14              if (lhs instanceof IdentNode) {
    1.15                  if (!checkIdentLValue((IdentNode)lhs)) {
    1.16 -                    return referenceError(lhs, rhs);
    1.17 +                    return referenceError(lhs, rhs, false);
    1.18                  }
    1.19                  verifyStrictIdent((IdentNode)lhs, "assignment");
    1.20              }
    1.21 @@ -2617,7 +2614,10 @@
    1.22          }
    1.23      }
    1.24  
    1.25 -    private static RuntimeNode referenceError(final Node lhs, final Node rhs) {
    1.26 +    private RuntimeNode referenceError(final Node lhs, final Node rhs, final boolean earlyError) {
    1.27 +        if (earlyError) {
    1.28 +            throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken());
    1.29 +        }
    1.30          final ArrayList<Node> args = new ArrayList<>();
    1.31          args.add(lhs);
    1.32          if (rhs == null) {
    1.33 @@ -2695,18 +2695,18 @@
    1.34              final Node lhs = leftHandSideExpression();
    1.35              // ++, -- without operand..
    1.36              if (lhs == null) {
    1.37 -                // error would have been issued when looking for 'lhs'
    1.38 -                return null;
    1.39 +                throw error(AbstractParser.message("expected.lvalue", type.getNameOrType()));
    1.40              }
    1.41 +
    1.42              if (!(lhs instanceof AccessNode ||
    1.43                    lhs instanceof IndexNode ||
    1.44                    lhs instanceof IdentNode)) {
    1.45 -                return referenceError(lhs, null);
    1.46 +                return referenceError(lhs, null, env._early_lvalue_error);
    1.47              }
    1.48  
    1.49              if (lhs instanceof IdentNode) {
    1.50                  if (!checkIdentLValue((IdentNode)lhs)) {
    1.51 -                    return referenceError(lhs, null);
    1.52 +                    return referenceError(lhs, null, false);
    1.53                  }
    1.54                  verifyStrictIdent((IdentNode)lhs, "operand for " + opType.getName() + " operator");
    1.55              }
    1.56 @@ -2725,16 +2725,21 @@
    1.57              case DECPREFIX:
    1.58                  final TokenType opType = type;
    1.59                  final Node lhs = expression;
    1.60 +                // ++, -- without operand..
    1.61 +                if (lhs == null) {
    1.62 +                    throw error(AbstractParser.message("expected.lvalue", type.getNameOrType()));
    1.63 +                }
    1.64 +
    1.65                  if (!(lhs instanceof AccessNode ||
    1.66                     lhs instanceof IndexNode ||
    1.67                     lhs instanceof IdentNode)) {
    1.68                      next();
    1.69 -                    return referenceError(lhs, null);
    1.70 +                    return referenceError(lhs, null, env._early_lvalue_error);
    1.71                  }
    1.72                  if (lhs instanceof IdentNode) {
    1.73                      if (!checkIdentLValue((IdentNode)lhs)) {
    1.74                          next();
    1.75 -                        return referenceError(lhs, null);
    1.76 +                        return referenceError(lhs, null, false);
    1.77                      }
    1.78                      verifyStrictIdent((IdentNode)lhs, "operand for " + opType.getName() + " operator");
    1.79                  }
     2.1 --- a/src/jdk/nashorn/internal/runtime/resources/Messages.properties	Tue Jul 02 14:50:39 2013 +0200
     2.2 +++ b/src/jdk/nashorn/internal/runtime/resources/Messages.properties	Tue Jul 02 15:01:38 2013 +0200
     2.3 @@ -43,6 +43,7 @@
     2.4  parser.error.expected.stmt=Expected statement but found {0}
     2.5  parser.error.expected.comma=Expected comma but found {0}
     2.6  parser.error.expected.property.id=Expected property id but found {0}
     2.7 +parser.error.expected.lvalue=Expected l-value but found {0}
     2.8  parser.error.expected=Expected {0} but found {1}
     2.9  parser.error.invalid.return=Invalid return statement
    2.10  parser.error.no.func.decl.here=Function declarations can only occur at program or function body level. You should use a function expression here instead.
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/script/basic/JDK-8019553.js	Tue Jul 02 15:01:38 2013 +0200
     3.3 @@ -0,0 +1,43 @@
     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-8019553:  NPE on illegal l-value for increment and decrement
    3.29 + *
    3.30 + * @test
    3.31 + * @run
    3.32 + */
    3.33 +
    3.34 +function check(str) {
    3.35 +    try {
    3.36 +        eval(str);
    3.37 +        fail("SyntaxError expected for: " + str);
    3.38 +    } catch (e) {
    3.39 +        print(e.toString().replace(/\\/g, '/'));
    3.40 +    }
    3.41 +}
    3.42 +
    3.43 +check("++ +3");
    3.44 +check("++ -7");
    3.45 +check("-- +2");
    3.46 +check("-- -8");
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/script/basic/JDK-8019553.js.EXPECTED	Tue Jul 02 15:01:38 2013 +0200
     4.3 @@ -0,0 +1,12 @@
     4.4 +SyntaxError: test/script/basic/JDK-8019553.js#33<eval>:1:3 Expected l-value but found +
     4.5 +++ +3
     4.6 +   ^
     4.7 +SyntaxError: test/script/basic/JDK-8019553.js#33<eval>:1:3 Expected l-value but found -
     4.8 +++ -7
     4.9 +   ^
    4.10 +SyntaxError: test/script/basic/JDK-8019553.js#33<eval>:1:3 Expected l-value but found +
    4.11 +-- +2
    4.12 +   ^
    4.13 +SyntaxError: test/script/basic/JDK-8019553.js#33<eval>:1:3 Expected l-value but found -
    4.14 +-- -8
    4.15 +   ^
     5.1 --- a/test/script/basic/NASHORN-51.js	Tue Jul 02 14:50:39 2013 +0200
     5.2 +++ b/test/script/basic/NASHORN-51.js	Tue Jul 02 15:01:38 2013 +0200
     5.3 @@ -35,28 +35,28 @@
     5.4          eval(literals[i] + "++");
     5.5          print("ERROR!! post increment : " + literals[i]);
     5.6      } catch (e) {
     5.7 -        print(e);
     5.8 +        print(e.toString().replace(/\\/g, '/'));
     5.9      }
    5.10  
    5.11      try {
    5.12          eval(literals[i] + "--");
    5.13          print("ERROR!! post decrement : " + literals[i]);
    5.14      } catch (e) {
    5.15 -        print(e);
    5.16 +        print(e.toString().replace(/\\/g, '/'));
    5.17      }
    5.18  
    5.19      try {
    5.20          eval("++" + literals[i]);
    5.21          print("ERROR!! pre increment : " + literals[i]);
    5.22      } catch (e) {
    5.23 -        print(e);
    5.24 +        print(e.toString().replace(/\\/g, '/'));
    5.25      }
    5.26  
    5.27      try {
    5.28          eval("--" + literals[i]);
    5.29          print("ERROR!! pre decrement : " + literals[i]);
    5.30      } catch (e) {
    5.31 -        print(e);
    5.32 +        print(e.toString().replace(/\\/g, '/'));
    5.33      }
    5.34  }
    5.35  
     6.1 --- a/test/script/basic/NASHORN-51.js.EXPECTED	Tue Jul 02 14:50:39 2013 +0200
     6.2 +++ b/test/script/basic/NASHORN-51.js.EXPECTED	Tue Jul 02 15:01:38 2013 +0200
     6.3 @@ -1,24 +1,72 @@
     6.4 -ReferenceError: "1" can not be used as the left-hand side of assignment
     6.5 -ReferenceError: "1" can not be used as the left-hand side of assignment
     6.6 -ReferenceError: "1" can not be used as the left-hand side of assignment
     6.7 -ReferenceError: "1" can not be used as the left-hand side of assignment
     6.8 -ReferenceError: "0" can not be used as the left-hand side of assignment
     6.9 -ReferenceError: "0" can not be used as the left-hand side of assignment
    6.10 -ReferenceError: "0" can not be used as the left-hand side of assignment
    6.11 -ReferenceError: "0" can not be used as the left-hand side of assignment
    6.12 -ReferenceError: "3.14" can not be used as the left-hand side of assignment
    6.13 -ReferenceError: "3.14" can not be used as the left-hand side of assignment
    6.14 -ReferenceError: "3.14" can not be used as the left-hand side of assignment
    6.15 -ReferenceError: "3.14" can not be used as the left-hand side of assignment
    6.16 -ReferenceError: "true" can not be used as the left-hand side of assignment
    6.17 -ReferenceError: "true" can not be used as the left-hand side of assignment
    6.18 -ReferenceError: "true" can not be used as the left-hand side of assignment
    6.19 -ReferenceError: "true" can not be used as the left-hand side of assignment
    6.20 -ReferenceError: "false" can not be used as the left-hand side of assignment
    6.21 -ReferenceError: "false" can not be used as the left-hand side of assignment
    6.22 -ReferenceError: "false" can not be used as the left-hand side of assignment
    6.23 -ReferenceError: "false" can not be used as the left-hand side of assignment
    6.24 -ReferenceError: "null" can not be used as the left-hand side of assignment
    6.25 -ReferenceError: "null" can not be used as the left-hand side of assignment
    6.26 -ReferenceError: "null" can not be used as the left-hand side of assignment
    6.27 -ReferenceError: "null" can not be used as the left-hand side of assignment
    6.28 +ReferenceError: test/script/basic/NASHORN-51.js#35<eval>:1:0 Invalid left hand side for assignment
    6.29 +1++
    6.30 +^
    6.31 +ReferenceError: test/script/basic/NASHORN-51.js#42<eval>:1:0 Invalid left hand side for assignment
    6.32 +1--
    6.33 +^
    6.34 +ReferenceError: test/script/basic/NASHORN-51.js#49<eval>:1:2 Invalid left hand side for assignment
    6.35 +++1
    6.36 +  ^
    6.37 +ReferenceError: test/script/basic/NASHORN-51.js#56<eval>:1:2 Invalid left hand side for assignment
    6.38 +--1
    6.39 +  ^
    6.40 +ReferenceError: test/script/basic/NASHORN-51.js#35<eval>:1:0 Invalid left hand side for assignment
    6.41 +0++
    6.42 +^
    6.43 +ReferenceError: test/script/basic/NASHORN-51.js#42<eval>:1:0 Invalid left hand side for assignment
    6.44 +0--
    6.45 +^
    6.46 +ReferenceError: test/script/basic/NASHORN-51.js#49<eval>:1:2 Invalid left hand side for assignment
    6.47 +++0
    6.48 +  ^
    6.49 +ReferenceError: test/script/basic/NASHORN-51.js#56<eval>:1:2 Invalid left hand side for assignment
    6.50 +--0
    6.51 +  ^
    6.52 +ReferenceError: test/script/basic/NASHORN-51.js#35<eval>:1:0 Invalid left hand side for assignment
    6.53 +3.14++
    6.54 +^
    6.55 +ReferenceError: test/script/basic/NASHORN-51.js#42<eval>:1:0 Invalid left hand side for assignment
    6.56 +3.14--
    6.57 +^
    6.58 +ReferenceError: test/script/basic/NASHORN-51.js#49<eval>:1:2 Invalid left hand side for assignment
    6.59 +++3.14
    6.60 +  ^
    6.61 +ReferenceError: test/script/basic/NASHORN-51.js#56<eval>:1:2 Invalid left hand side for assignment
    6.62 +--3.14
    6.63 +  ^
    6.64 +ReferenceError: test/script/basic/NASHORN-51.js#35<eval>:1:0 Invalid left hand side for assignment
    6.65 +true++
    6.66 +^
    6.67 +ReferenceError: test/script/basic/NASHORN-51.js#42<eval>:1:0 Invalid left hand side for assignment
    6.68 +true--
    6.69 +^
    6.70 +ReferenceError: test/script/basic/NASHORN-51.js#49<eval>:1:2 Invalid left hand side for assignment
    6.71 +++true
    6.72 +  ^
    6.73 +ReferenceError: test/script/basic/NASHORN-51.js#56<eval>:1:2 Invalid left hand side for assignment
    6.74 +--true
    6.75 +  ^
    6.76 +ReferenceError: test/script/basic/NASHORN-51.js#35<eval>:1:0 Invalid left hand side for assignment
    6.77 +false++
    6.78 +^
    6.79 +ReferenceError: test/script/basic/NASHORN-51.js#42<eval>:1:0 Invalid left hand side for assignment
    6.80 +false--
    6.81 +^
    6.82 +ReferenceError: test/script/basic/NASHORN-51.js#49<eval>:1:2 Invalid left hand side for assignment
    6.83 +++false
    6.84 +  ^
    6.85 +ReferenceError: test/script/basic/NASHORN-51.js#56<eval>:1:2 Invalid left hand side for assignment
    6.86 +--false
    6.87 +  ^
    6.88 +ReferenceError: test/script/basic/NASHORN-51.js#35<eval>:1:0 Invalid left hand side for assignment
    6.89 +null++
    6.90 +^
    6.91 +ReferenceError: test/script/basic/NASHORN-51.js#42<eval>:1:0 Invalid left hand side for assignment
    6.92 +null--
    6.93 +^
    6.94 +ReferenceError: test/script/basic/NASHORN-51.js#49<eval>:1:2 Invalid left hand side for assignment
    6.95 +++null
    6.96 +  ^
    6.97 +ReferenceError: test/script/basic/NASHORN-51.js#56<eval>:1:2 Invalid left hand side for assignment
    6.98 +--null
    6.99 +  ^
     7.1 --- a/test/script/error/NASHORN-57.js.EXPECTED	Tue Jul 02 14:50:39 2013 +0200
     7.2 +++ b/test/script/error/NASHORN-57.js.EXPECTED	Tue Jul 02 15:01:38 2013 +0200
     7.3 @@ -1,3 +1,3 @@
     7.4 -test/script/error/NASHORN-57.js:35:2 Expected statement but found ;
     7.5 +test/script/error/NASHORN-57.js:35:2 Expected l-value but found ;
     7.6  ++;
     7.7    ^

mercurial