From 65bd8f3f3c2b25c4b3086c44d241069033555aae Mon Sep 17 00:00:00 2001 From: "igor%mir2.org" Date: Wed, 12 Jan 2005 14:21:06 +0000 Subject: [PATCH] Fixing bug 277935: now parser throws syntax error on assignments to descendants like x..y = 1 --- js/rhino/src/org/mozilla/javascript/IRFactory.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/rhino/src/org/mozilla/javascript/IRFactory.java b/js/rhino/src/org/mozilla/javascript/IRFactory.java index b378c30c119..b9a52042cec 100644 --- a/js/rhino/src/org/mozilla/javascript/IRFactory.java +++ b/js/rhino/src/org/mozilla/javascript/IRFactory.java @@ -1239,6 +1239,7 @@ final class IRFactory } case Token.GET_REF: { Node ref = left.getFirstChild(); + checkMutableReference(ref); return new Node(Token.SET_REF, ref, right); } } @@ -1246,6 +1247,14 @@ final class IRFactory throw Kit.codeBug(); } + private void checkMutableReference(Node n) + { + int memberTypeFlags = n.getIntProp(Node.MEMBER_TYPE_PROP, 0); + if ((memberTypeFlags & Node.DESCENDANTS_FLAG) != 0) { + parser.reportError("msg.bad.assign.left"); + } + } + Node createAssignment(int assignType, Node left, Node right) { left = makeReference(left); @@ -1297,6 +1306,7 @@ final class IRFactory } case Token.GET_REF: { Node ref = left.getFirstChild(); + checkMutableReference(ref); Node opLeft = new Node(Token.USE_STACK); Node op = new Node(assignOp, opLeft, right); return new Node(Token.SET_REF_OP, ref, op);