branch: master
commit b904d10efedf93040b6da38e6bea1204caee11e7
Merge: 6aba571 c0e0309
Author: Dmitry Gutov <[email protected]>
Commit: Dmitry Gutov <[email protected]>
Merge pull request #279 from XeCycle/class-semicolon-elem
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() {}"