branch: master
commit c0e03098ad8fb3496f2ad7ff63b7ae4ac7f817fa
Author: Carl Lei <[email protected]>
Commit: Carl Lei <[email protected]>
Allow semicolons in a class body
---
js2-mode.el | 4 ++++
tests/parser.el | 3 +++
2 files changed, 7 insertions(+)
diff --git a/js2-mode.el b/js2-mode.el
index c98917c..865f287 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -10649,6 +10649,10 @@ expression)."
(if after-comma
(js2-parse-warn-trailing-comma "msg.extra.trailing.comma"
pos elems after-comma)))
+ ;; Skip semicolons in a class body
+ ((and class-p
+ (= tt js2-SEMI))
+ nil)
(t
(js2-report-error "msg.bad.prop")
(unless js2-recover-from-parse-errors
diff --git a/tests/parser.el b/tests/parser.el
index 650bac8..c65be2c 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -766,6 +766,9 @@ the test."
(js2-deftest-parse parse-class-keywordlike-method
"class C {\n delete() {}\n if() {}\n}")
+(js2-deftest-parse parse-harmony-class-allow-semicolon-element
+ "class Foo {;}" :reference "class Foo {\n}")
+
;;; Scopes
(js2-deftest ast-symbol-table-includes-fn-node "function foo() {}"