aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsundar <none@none>2014-01-08 17:51:47 +0530
committersundar <none@none>2014-01-08 17:51:47 +0530
commit03b7763e1efd33fdec735b34d8c847c259b087cf (patch)
treefb685eb7d9324107a5f0cc1af45fdc9017b9dd59 /src
parent1df080774ae7a4cd3c382e348a9afb32cb94622d (diff)
downloadnashorn-03b7763e1efd33fdec735b34d8c847c259b087cf.tar.gz
8031317: SyntaxError when property setter has no parameter
Reviewed-by: lagergren, hannesw
Diffstat (limited to 'src')
-rw-r--r--src/jdk/nashorn/internal/parser/Parser.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/jdk/nashorn/internal/parser/Parser.java b/src/jdk/nashorn/internal/parser/Parser.java
index 7b9150c4..6ac18d09 100644
--- a/src/jdk/nashorn/internal/parser/Parser.java
+++ b/src/jdk/nashorn/internal/parser/Parser.java
@@ -2134,11 +2134,20 @@ loop:
final String setterName = setIdent.getPropertyName();
final IdentNode setNameNode = new IdentNode(((Node)setIdent).getToken(), finish, NameCodec.encode("set " + setterName));
expect(LPAREN);
- final IdentNode argIdent = getIdent();
- verifyStrictIdent(argIdent, "setter argument");
+ // be sloppy and allow missing setter parameter even though
+ // spec does not permit it!
+ final IdentNode argIdent;
+ if (type == IDENT || isNonStrictModeIdent()) {
+ argIdent = getIdent();
+ verifyStrictIdent(argIdent, "setter argument");
+ } else {
+ argIdent = null;
+ }
expect(RPAREN);
List<IdentNode> parameters = new ArrayList<>();
- parameters.add(argIdent);
+ if (argIdent != null) {
+ parameters.add(argIdent);
+ }
functionNode = functionBody(getSetToken, setNameNode, parameters, FunctionNode.Kind.SETTER);
return new PropertyNode(propertyToken, finish, setIdent, null, null, functionNode);