branch: externals/js2-mode
commit 515d876c6ae45a61cf67a7bd5723fe4c9e518756
Author: Dmitry Gutov <dgu...@yandex.ru>
Commit: Dmitry Gutov <dgu...@yandex.ru>

    Fix parsing static props without semicolons
    
    Fixes #477
---
 js2-mode.el     | 8 ++++++++
 tests/parser.el | 3 +++
 2 files changed, 11 insertions(+)

diff --git a/js2-mode.el b/js2-mode.el
index 64cc72c..924bc03 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -10960,6 +10960,14 @@ expression)."
         elem-key-string previous-elem-key-string
         after-comma previous-token)
     (while continue
+      ;; Clear out any lookahead tokens (possibly wrong modifier).
+      ;; FIXME: Deal with this problem in a more systematic fashion.
+      ;; Perhaps by making this modifier affect not how the token
+      ;; struct is constructed, but when js2-get-token returns based
+      ;; on it.
+      (when (> js2-ti-lookahead 0)
+        (setq js2-ti-lookahead 0)
+        (setq js2-ts-cursor (js2-current-token-end)))
       (setq tt (js2-get-prop-name-token)
             static nil
             elem nil
diff --git a/tests/parser.el b/tests/parser.el
index c87fa5f..2ad8b62 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -982,6 +982,9 @@ the test."
 (js2-deftest-parse parse-class-public-field-computed
   "class C {\n  [a + b] = c\n}")
 
+(js2-deftest-parse parse-class-static-fields-no-semi
+  "class C {\n  static a\n  static b = 42\n}")
+
 ;;; Operators
 
 (js2-deftest-parse exponentiation

Reply via email to