emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master e6cb7bf 15/33: with statements are syntax errors in strict


From: Dmitry Gutov
Subject: [elpa] master e6cb7bf 15/33: with statements are syntax errors in strict mode
Date: Sun, 12 Jul 2015 22:35:39 +0000

branch: master
commit e6cb7bfc53b100d484487850b18a82cc57464e4f
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>

    with statements are syntax errors in strict mode
---
 js2-mode.el     |    5 +++++
 tests/parser.el |    6 ++++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/js2-mode.el b/js2-mode.el
index 12801bb..d47fc80 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -1671,6 +1671,9 @@ the correct number of ARGS must be provided."
 (js2-msg "msg.no.paren.after.with"
          "missing ) after with-statement object")
 
+(js2-msg "msg.no.with.strict"
+         "with statements not allowed in strict mode")
+
 (js2-msg "msg.no.paren.after.let"
          "missing ( after let")
 
@@ -9141,6 +9144,8 @@ does not match an existing label, reports an error and 
returns nil."
 
 (defun js2-parse-with ()
   "Parser for with-statement.  Last matched token must be js2-WITH."
+  (when js2-in-use-strict-directive
+    (js2-report-error "msg.no.with.strict"))
   (let ((pos (js2-current-token-beg))
         obj body pn lp rp)
     (if (js2-must-match js2-LP "msg.no.paren.with")
diff --git a/tests/parser.el b/tests/parser.el
index a3b693b..04a19c3 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -281,6 +281,12 @@ the test."
   "'use strict';\narguments = 'fufufu';"
   :syntax-error "arguments" :errors-count 1)
 
+;;; Strict syntax errors
+
+(js2-deftest-parse function-strict-with
+  "'use strict';\nwith ({}) {}"
+  :syntax-error "with" :errors-count 1)
+
 ;;; Spread operator
 
 (js2-deftest-parse spread-in-array-literal



reply via email to

[Prev in Thread] Current Thread [Next in Thread]