From 877212964db12706d9610ee2abc1ef3d1aacf3da Mon Sep 17 00:00:00 2001 From: "igor%mir2.org" Date: Mon, 23 Aug 2004 23:01:00 +0000 Subject: [PATCH] Fixing bug 256621: throw \n 1 is not allowed per ECMA 262 --- .../src/org/mozilla/javascript/Parser.java | 6 +++++ .../javascript/resources/Messages.properties | 23 +++++++++++-------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/js/rhino/src/org/mozilla/javascript/Parser.java b/js/rhino/src/org/mozilla/javascript/Parser.java index 992606459b79..cff347108321 100644 --- a/js/rhino/src/org/mozilla/javascript/Parser.java +++ b/js/rhino/src/org/mozilla/javascript/Parser.java @@ -931,6 +931,12 @@ public class Parser case Token.THROW: { consumeToken(); + if (peekTokenOrEOL(TokenStream.TSF_REGEXP) == Token.EOL) { + // ECMAScript does not allow new lines before throw expression, + // see bug 256617 + reportError("msg.bad.throw.eol"); + } + int lineno = ts.getLineno(); decompiler.addToken(Token.THROW); pn = nf.createThrow(expr(false), lineno); diff --git a/js/rhino/src/org/mozilla/javascript/resources/Messages.properties b/js/rhino/src/org/mozilla/javascript/resources/Messages.properties index 702b50d3830a..ff1dd8cc660f 100644 --- a/js/rhino/src/org/mozilla/javascript/resources/Messages.properties +++ b/js/rhino/src/org/mozilla/javascript/resources/Messages.properties @@ -224,34 +224,37 @@ msg.bad.backref =\ msg.bad.regexp.compile =\ Only one argument may be specified if the first argument to \ - RegExp.prototype.compile is a RegExp object + RegExp.prototype.compile is a RegExp object. -# Compilation API +# Parser msg.got.syntax.errors = \ Compilation produced {0} syntax errors. # NodeTransformer msg.dup.label =\ - Duplicate label. + duplicatet label msg.undef.label =\ - Undefined label. + undefined labe msg.bad.break =\ - Unlabelled break must be inside loop or switch. + unlabelled break must be inside loop or switch msg.continue.outside =\ - continue must be inside loop. + continue must be inside loop msg.continue.nonloop =\ - Can only continue to labeled iteration statement. + continue can only use labeles of iteration statements msg.fn.redecl =\ - Function "{0}" redeclared; prior definition will be ignored. + function "{0}" redeclared; prior definition will be ignored + +msg.bad.throw.eol =\ + Line terminator is not allowed between the throw keyword and throw \ + expression. -# Parser msg.no.paren.parms =\ - missing ( before function parameters + missing ( before function parameters. msg.no.parm =\ missing formal parameter