[X2Go-Commits] [pale-moon] 217/294: Track strict mode errors in unary deletions correctly when syntax-parsing.

git-admin at x2go.org git-admin at x2go.org
Sat Apr 27 08:58:18 CEST 2019


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch upstream/28.5.0
in repository pale-moon.

commit 11a1f58b9a0ebf83c17087a89e6b4ba83748374a
Author: wolfbeast <mcwerewolf at wolfbeast.com>
Date:   Fri Apr 5 21:32:55 2019 +0200

    Track strict mode errors in unary deletions correctly when
    syntax-parsing.
---
 js/src/frontend/Parser.cpp | 19 +++++++++++++++++--
 js/src/frontend/Parser.h   |  7 +++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp
index afbf4c4..f625595 100644
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -643,6 +643,17 @@ Parser<ParseHandler>::strictModeError(unsigned errorNumber, ...)
 
 template <typename ParseHandler>
 bool
+Parser<ParseHandler>::strictModeErrorAt(uint32_t offset, unsigned errorNumber, ...)
+{
+    va_list args;
+    va_start(args, errorNumber);
+    bool res = reportHelper(ParseStrictError, pc->sc()->strict(), offset, errorNumber, args);
+    va_end(args);
+    return res;
+}
+
+template <typename ParseHandler>
+bool
 Parser<ParseHandler>::reportWithNode(ParseReportKind kind, bool strict, Node pn, unsigned errorNumber, ...)
 {
     uint32_t offset = (pn ? handler.getPosition(pn) : pos()).begin;
@@ -8031,6 +8042,10 @@ Parser<ParseHandler>::unaryExpr(YieldHandling yieldHandling, TripledotHandling t
       }
 
       case TOK_DELETE: {
+        uint32_t exprOffset;
+        if (!tokenStream.peekOffset(&exprOffset, TokenStream::Operand))
+            return null();
+
         Node expr = unaryExpr(yieldHandling, TripledotProhibited);
         if (!expr)
             return null();
@@ -8038,9 +8053,9 @@ Parser<ParseHandler>::unaryExpr(YieldHandling yieldHandling, TripledotHandling t
         // Per spec, deleting any unary expression is valid -- it simply
         // returns true -- except for one case that is illegal in strict mode.
         if (handler.isNameAnyParentheses(expr)) {
-            bool strict = pc->sc()->strict();
-            if (!reportWithNode(ParseStrictError, strict, expr, JSMSG_DEPRECATED_DELETE_OPERAND))
+            if (!strictModeErrorAt(exprOffset, JSMSG_DEPRECATED_DELETE_OPERAND))
                 return null();
+
             pc->sc()->setBindingsAccessedDynamically();
         }
 
diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h
index feead0e..c8914a2 100644
--- a/js/src/frontend/Parser.h
+++ b/js/src/frontend/Parser.h
@@ -922,6 +922,13 @@ class Parser final : private JS::AutoGCRooter, public StrictModeGetter
      */
     MOZ_MUST_USE bool strictModeError(unsigned errorNumber, ...);
 
+    /*
+     * Handle a strict mode error at the given offset.  Report an error if in
+     * strict mode code, or warn if not, using the given error number and
+     * arguments.
+     */
+    MOZ_MUST_USE bool strictModeErrorAt(uint32_t offset, unsigned errorNumber, ...);
+
     /* Report the given warning at the current offset. */
     MOZ_MUST_USE bool warning(unsigned errorNumber, ...);
 

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/pale-moon.git


More information about the x2go-commits mailing list