diff --git a/js/rhino/src/org/mozilla/javascript/IRFactory.java b/js/rhino/src/org/mozilla/javascript/IRFactory.java index fbd704814bd..d57a151de78 100644 --- a/js/rhino/src/org/mozilla/javascript/IRFactory.java +++ b/js/rhino/src/org/mozilla/javascript/IRFactory.java @@ -82,6 +82,11 @@ public class IRFactory { return new Node(nodeType, nodeOp); } + public int getLeafType(Object leaf) { + Node n = (Node) leaf; + return n.getType(); + } + /** * Statement leaf nodes. */ diff --git a/js/rhino/src/org/mozilla/javascript/Parser.java b/js/rhino/src/org/mozilla/javascript/Parser.java index 3d3ecb51b83..61fcf1313f4 100644 --- a/js/rhino/src/org/mozilla/javascript/Parser.java +++ b/js/rhino/src/org/mozilla/javascript/Parser.java @@ -809,8 +809,12 @@ class Parser { return pn; } - if (lastExprType == ts.FUNCTION) + if (lastExprType == ts.FUNCTION) { + if (nf.getLeafType(pn) != ts.FUNCTION) { + reportError(ts, "msg.syntax"); + } nf.setFunctionExpressionStatement(pn); + } pn = nf.createExprStatement(pn, lineno);