@@ -8032,9 +8032,10 @@ string is NAME. Returns nil and keeps current token otherwise."
8032
8032
(defun js2-match-async-function ()
8033
8033
(when (and (js2-contextual-kwd-p (js2-current-token) "async")
8034
8034
(= (js2-peek-token) js2-FUNCTION))
8035
- (js2-record-face 'font-lock-keyword-face)
8036
- (js2-get-token)
8037
- t))
8035
+ (let ((async-pos (js2-current-token-beg)))
8036
+ (js2-record-face 'font-lock-keyword-face)
8037
+ (js2-get-token)
8038
+ async-pos)))
8038
8039
8039
8040
(defun js2-match-async-arrow-function ()
8040
8041
(and (js2-contextual-kwd-p (js2-current-token) "async")
@@ -8503,37 +8504,34 @@ Last token scanned is the close-curly for the function body."
8503
8504
(js2-name-node-name name) pos end)
8504
8505
(js2-add-strict-warning "msg.anon.no.return.value" nil pos end)))))
8505
8506
8506
- (defun js2-parse-function-stmt (&optional async-p )
8507
- (let ((pos (js2-current-token-beg))
8507
+ (defun js2-parse-function-stmt (&optional async-pos )
8508
+ (let ((pos (or async-pos ( js2-current-token-beg) ))
8508
8509
(star-p (js2-match-token js2-MUL)))
8509
8510
(js2-must-match-name "msg.unnamed.function.stmt")
8510
8511
(let ((name (js2-create-name-node t))
8511
8512
pn member-expr)
8512
8513
(cond
8513
8514
((js2-match-token js2-LP)
8514
- (js2-parse-function 'FUNCTION_STATEMENT pos star-p async-p name))
8515
+ (js2-parse-function 'FUNCTION_STATEMENT pos star-p async-pos name))
8515
8516
(js2-allow-member-expr-as-function-name
8516
8517
(setq member-expr (js2-parse-member-expr-tail nil name))
8517
8518
(js2-parse-highlight-member-expr-fn-name member-expr)
8518
8519
(js2-must-match js2-LP "msg.no.paren.parms")
8519
- (setf pn (js2-parse-function 'FUNCTION_STATEMENT pos star-p async-p )
8520
+ (setf pn (js2-parse-function 'FUNCTION_STATEMENT pos star-p async-pos )
8520
8521
(js2-function-node-member-expr pn) member-expr)
8521
8522
pn)
8522
8523
(t
8523
8524
(js2-report-error "msg.no.paren.parms")
8524
8525
(make-js2-error-node))))))
8525
8526
8526
- (defun js2-parse-async-function-stmt ()
8527
- (js2-parse-function-stmt t))
8528
-
8529
- (defun js2-parse-function-expr (&optional async-p)
8530
- (let ((pos (js2-current-token-beg))
8527
+ (defun js2-parse-function-expr (&optional async-pos)
8528
+ (let ((pos (or async-pos (js2-current-token-beg)))
8531
8529
(star-p (js2-match-token js2-MUL))
8532
8530
name)
8533
8531
(when (js2-match-token js2-NAME)
8534
8532
(setq name (js2-create-name-node t)))
8535
8533
(js2-must-match js2-LP "msg.no.paren.parms")
8536
- (js2-parse-function 'FUNCTION_EXPRESSION pos star-p async-p name)))
8534
+ (js2-parse-function 'FUNCTION_EXPRESSION pos star-p async-pos name)))
8537
8535
8538
8536
(defun js2-parse-function-internal (function-type pos star-p &optional async-p name)
8539
8537
(let (fn-node lp)
@@ -8725,11 +8723,11 @@ node are given relative start positions and correct lengths."
8725
8723
(defun js2-statement-helper ()
8726
8724
(let* ((tt (js2-get-token))
8727
8725
(first-tt tt)
8728
- (async-stmt (js2-match-async-function))
8726
+ (async-pos (js2-match-async-function))
8729
8727
(parser (if (= tt js2-ERROR)
8730
8728
#'js2-parse-semi
8731
- (if async-stmt
8732
- #'js2-parse-async- function-stmt
8729
+ (if async-pos
8730
+ (apply-partially #'js2-parse-function-stmt async-pos)
8733
8731
(aref js2-parsers tt))))
8734
8732
pn)
8735
8733
;; If the statement is set, then it's been told its label by now.
@@ -8740,7 +8738,7 @@ node are given relative start positions and correct lengths."
8740
8738
;; Don't do auto semi insertion for certain statement types.
8741
8739
(unless (or (memq first-tt js2-no-semi-insertion)
8742
8740
(js2-labeled-stmt-node-p pn)
8743
- async-stmt )
8741
+ async-pos )
8744
8742
(js2-auto-insert-semicolon pn))
8745
8743
pn))
8746
8744
@@ -9140,7 +9138,8 @@ invalid export statements."
9140
9138
(js2-report-error "msg.mod.export.decl.at.top.level"))
9141
9139
(let ((beg (js2-current-token-beg))
9142
9140
(children (list))
9143
- exports-list from-clause declaration default)
9141
+ exports-list from-clause declaration default
9142
+ async-pos)
9144
9143
(cond
9145
9144
((js2-match-token js2-MUL)
9146
9145
(setq from-clause (js2-parse-from-clause))
@@ -9160,10 +9159,10 @@ invalid export statements."
9160
9159
(js2-parse-class-stmt)
9161
9160
(js2-parse-class-expr)))
9162
9161
((js2-match-token js2-NAME)
9163
- (if (js2-match-async-function)
9162
+ (if (setq async-pos ( js2-match-async-function) )
9164
9163
(if (eq (js2-peek-token) js2-NAME)
9165
- (js2-parse-async- function-stmt)
9166
- (js2-parse-function-expr t ))
9164
+ (js2-parse-function-stmt async-pos )
9165
+ (js2-parse-function-expr async-pos ))
9167
9166
(js2-unget-token)
9168
9167
(js2-parse-expr)))
9169
9168
((js2-match-token js2-FUNCTION)
@@ -9177,8 +9176,8 @@ invalid export statements."
9177
9176
(setq declaration (js2-parse-class-stmt)))
9178
9177
((js2-match-token js2-NAME)
9179
9178
(setq declaration
9180
- (if (js2-match-async-function)
9181
- (js2-parse-async- function-stmt)
9179
+ (if (setq async-pos ( js2-match-async-function) )
9180
+ (js2-parse-function-stmt async-pos )
9182
9181
(js2-unget-token)
9183
9182
(js2-parse-expr))))
9184
9183
((js2-match-token js2-FUNCTION)
@@ -10698,15 +10697,15 @@ For instance, @[expr], @*::[expr], or ns::[expr]."
10698
10697
"Parse a literal (leaf) expression of some sort.
10699
10698
Includes complex literals such as functions, object-literals,
10700
10699
array-literals, array comprehensions and regular expressions."
10701
- (let (tt node)
10700
+ (let (tt node async-pos )
10702
10701
(setq tt (js2-current-token-type))
10703
10702
(cond
10704
10703
((= tt js2-CLASS)
10705
10704
(js2-parse-class-expr))
10706
10705
((= tt js2-FUNCTION)
10707
10706
(js2-parse-function-expr))
10708
- ((js2-match-async-function)
10709
- (js2-parse-function-expr t ))
10707
+ ((setq async-pos ( js2-match-async-function) )
10708
+ (js2-parse-function-expr async-pos ))
10710
10709
((= tt js2-LB)
10711
10710
(js2-parse-array-comp-or-literal))
10712
10711
((= tt js2-LC)
0 commit comments