diff --git a/src/org/mozilla/javascript/Parser.java b/src/org/mozilla/javascript/Parser.java index 8c01726595..ab8559dea5 100644 --- a/src/org/mozilla/javascript/Parser.java +++ b/src/org/mozilla/javascript/Parser.java @@ -888,11 +888,13 @@ private FunctionNode function(int type, boolean isGenerator) throws IOException syntheticType = FunctionNode.FUNCTION_EXPRESSION; } - if (syntheticType != FunctionNode.FUNCTION_EXPRESSION - && name != null - && name.length() > 0) { - // Function statements define a symbol in the enclosing scope - defineSymbol(Token.FUNCTION, name.getIdentifier()); + if (syntheticType != FunctionNode.FUNCTION_EXPRESSION) { + if (name != null && name.length() > 0) { + // Function statements define a symbol in the enclosing scope + defineSymbol(Token.FUNCTION, name.getIdentifier()); + } else { + reportError("msg.fn.missing.name"); + } } FunctionNode fnNode = new FunctionNode(functionSourceStart, name); diff --git a/src/org/mozilla/javascript/resources/Messages.properties b/src/org/mozilla/javascript/resources/Messages.properties index d1d161939e..feb45fa40d 100644 --- a/src/org/mozilla/javascript/resources/Messages.properties +++ b/src/org/mozilla/javascript/resources/Messages.properties @@ -283,6 +283,9 @@ msg.let.decl.not.in.block =\ msg.bad.object.init =\ SyntaxError: invalid object initializer +msg.fn.missing.name =\ + SyntaxError: function statements require a function name + # NodeTransformer msg.dup.label =\ duplicated label