From: Jackson Hamilton Date: Sun, 3 Jan 2016 00:13:22 +0000 (-0800) Subject: Fix await parsing X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/83d98906e29ad69ecd6971d809425e2d79c4409f Fix await parsing --- diff --git a/js2-mode.el b/js2-mode.el index b20edd1a2..87a5f2c5d 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -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))) diff --git a/tests/parser.el b/tests/parser.el index b3c362053..211167105 100644 --- a/tests/parser.el +++ b/tests/parser.el @@ -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;")