From c4c76975f67711791378c20e40ff54f6196b81e6 Mon Sep 17 00:00:00 2001 From: "norris%netscape.com" Date: Fri, 3 Dec 1999 00:04:46 +0000 Subject: [PATCH] Fix the following bug: Subject: Rhino request URGENT Date: Thu, 02 Dec 1999 15:58:40 -0500 From: slobo@espialgroup.com To: Norris Boyd References: 1 , 2 Hello Norris In Rhino, the following script gives the error : "function does not always return a value" during the parsing phase. The script runs perfectly fine in Netscape 4.61. It is an urgent requirement. Many thanks in advance. Steven ///////////////////////////////////////////////////////SCRIPT BEGIN /////////////////////////////////////////////// function test (a) { this.arg = a; if (a>20) return; return this; } //print = alert; function joe() { a = new test (20); print (a.arg); a = new test (25); print (a.arg); } joe(); ///////////////////////////////////////////////////////SCRIPT END /////////////////////////////////////////////// --- js/rhino/org/mozilla/javascript/Parser.java | 5 +++-- js/rhino/org/mozilla/javascript/TokenStream.java | 2 +- js/rhino/src/org/mozilla/javascript/Parser.java | 5 +++-- js/rhino/src/org/mozilla/javascript/TokenStream.java | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/js/rhino/org/mozilla/javascript/Parser.java b/js/rhino/org/mozilla/javascript/Parser.java index c9fa87cfb138..13ddf9d3e9eb 100644 --- a/js/rhino/org/mozilla/javascript/Parser.java +++ b/js/rhino/org/mozilla/javascript/Parser.java @@ -688,8 +688,9 @@ class Parser { tt = ts.peekTokenSameLine(); ts.flags &= ~ts.TSF_REGEXP; - if (tt != ts.EOF && tt != ts.EOL - && tt != ts.SEMI && tt != ts.RC) { + if (tt != ts.EOF && tt != ts.EOL && tt != ts.SEMI && + tt != ts.RC && !(tt == ts.PRIMARY && ts.getOp() == ts.THIS)) + { lineno = ts.getLineno(); retExpr = expr(ts, source, false); if (ts.getLineno() == lineno) diff --git a/js/rhino/org/mozilla/javascript/TokenStream.java b/js/rhino/org/mozilla/javascript/TokenStream.java index d4345ed1ad8d..11e274b5f6bb 100644 --- a/js/rhino/org/mozilla/javascript/TokenStream.java +++ b/js/rhino/org/mozilla/javascript/TokenStream.java @@ -195,7 +195,7 @@ public class TokenStream { INC = 105, // increment/decrement (++ --) DEC = 106, DOT = 107, // member operator (.) - PRIMARY = 108, // true, false, null, this, super + PRIMARY = 108, // true, false, null, this FUNCTION = 109, // function keyword EXPORT = 110, // export keyword IMPORT = 111, // import keyword diff --git a/js/rhino/src/org/mozilla/javascript/Parser.java b/js/rhino/src/org/mozilla/javascript/Parser.java index c9fa87cfb138..13ddf9d3e9eb 100644 --- a/js/rhino/src/org/mozilla/javascript/Parser.java +++ b/js/rhino/src/org/mozilla/javascript/Parser.java @@ -688,8 +688,9 @@ class Parser { tt = ts.peekTokenSameLine(); ts.flags &= ~ts.TSF_REGEXP; - if (tt != ts.EOF && tt != ts.EOL - && tt != ts.SEMI && tt != ts.RC) { + if (tt != ts.EOF && tt != ts.EOL && tt != ts.SEMI && + tt != ts.RC && !(tt == ts.PRIMARY && ts.getOp() == ts.THIS)) + { lineno = ts.getLineno(); retExpr = expr(ts, source, false); if (ts.getLineno() == lineno) diff --git a/js/rhino/src/org/mozilla/javascript/TokenStream.java b/js/rhino/src/org/mozilla/javascript/TokenStream.java index d4345ed1ad8d..11e274b5f6bb 100644 --- a/js/rhino/src/org/mozilla/javascript/TokenStream.java +++ b/js/rhino/src/org/mozilla/javascript/TokenStream.java @@ -195,7 +195,7 @@ public class TokenStream { INC = 105, // increment/decrement (++ --) DEC = 106, DOT = 107, // member operator (.) - PRIMARY = 108, // true, false, null, this, super + PRIMARY = 108, // true, false, null, this FUNCTION = 109, // function keyword EXPORT = 110, // export keyword IMPORT = 111, // import keyword