]> code.delx.au - gnu-emacs-elpa/commitdiff
Fix await parsing
authorJackson Hamilton <jackson@jacksonrayhamilton.com>
Sun, 3 Jan 2016 00:13:22 +0000 (16:13 -0800)
committerJackson Hamilton <jackson@jacksonrayhamilton.com>
Sun, 3 Jan 2016 03:21:48 +0000 (19:21 -0800)
js2-mode.el
tests/parser.el

index b20edd1a2d2590a578c2c26c8e9e3e63d494bdc7..87a5f2c5d989740eae9e12d7238274c456a4b3b7 100644 (file)
@@ -7766,7 +7766,16 @@ string is NAME.  Returns nil and keeps current token otherwise."
 
 (defun js2-match-await (tt)
   (when (and (= tt js2-NAME)
-             (js2-contextual-kwd-p (js2-current-token) "await"))
+             (js2-contextual-kwd-p (js2-current-token) "await")
+             ;; Per the proposal, AwaitExpression consists of "await"
+             ;; followed by a UnaryExpression.  So look ahead for one.
+             (let ((ts-state (make-js2-ts-state))
+                   js2-recorded-identifiers
+                   js2-parsed-errors)
+               (js2-get-token)
+               (prog1
+                   (/= (js2-node-type (js2-parse-unary-expr)) js2-ERROR)
+                 (js2-ts-seek ts-state))))
     (js2-record-face 'font-lock-keyword-face)
     (let ((beg (js2-current-token-beg))
           (end (js2-current-token-end)))
index b3c362053d92e55927d3e76e1e0bc1603d4cc769..2111671059215a0508e1bb75e934c973f99252f2 100644 (file)
@@ -499,6 +499,12 @@ the test."
 (js2-deftest-parse async-can-be-function-name
   "function async() {\n}")
 
+(js2-deftest-parse await-can-be-name
+  "void await;")
+
+(js2-deftest-parse await-can-be-object-name
+  "await.z;")
+
 (js2-deftest-parse await-can-be-var-name
   "var await = 3;")