[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 34245fe 008/110: Don't treat getter / setter pairs as dupl
From: |
Dmitry Gutov |
Subject: |
[elpa] master 34245fe 008/110: Don't treat getter / setter pairs as duplicates |
Date: |
Thu, 23 Jun 2016 01:12:52 +0000 (UTC) |
branch: master
commit 34245fec536c0e22786b074e792873d8f2be84f5
Author: Jackson Hamilton <address@hidden>
Commit: Jackson Hamilton <address@hidden>
Don't treat getter / setter pairs as duplicates
Fixes #264
---
js2-mode.el | 8 +++++++-
tests/parser.el | 14 +++++++++++++-
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/js2-mode.el b/js2-mode.el
index 926003d..fc22efe 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -10654,7 +10654,13 @@ expression)."
(lambda (previous-elem)
(and (setq previous-elem-key-string
(js2-property-key-string previous-elem))
- (string= previous-elem-key-string elem-key-string)))
+ ;; Check if the property is a duplicate.
+ (string= previous-elem-key-string elem-key-string)
+ ;; But make an exception for getter / setter pairs.
+ (not (and (js2-getter-setter-node-p elem)
+ (js2-getter-setter-node-p previous-elem)
+ (/= (js2-getter-setter-node-type elem)
+ (js2-getter-setter-node-type
previous-elem))))))
elems))
(js2-report-error "msg.dup.obj.lit.prop.strict"
elem-key-string
diff --git a/tests/parser.el b/tests/parser.el
index dc8c001..17519ca 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -294,10 +294,22 @@ the test."
"'use strict';\nvar object = {a: 1, a: 2, 'a': 3, ['a']: 4, 1: 5, '1': 6, [1
+ 1]: 7};"
:syntax-error "a" :errors-count 4) ; "a" has 3 dupes, "1" has 1 dupe.
-;; errors... or lackthereof.
+(js2-deftest-parse function-strict-duplicate-getter
+ "'use strict';\nvar a = {get x() {}, get x() {}};"
+ :syntax-error "x" :errors-count 1)
+
+(js2-deftest-parse function-strict-duplicate-setter
+ "'use strict';\nvar a = {set x() {}, set x() {}};"
+ :syntax-error "x" :errors-count 1)
+
+;;; Lack of errors in strict mode
+
(js2-deftest-parse function-strict-const-scope
"'use strict';\nconst a;\nif (1) {\n const a;\n}")
+(js2-deftest-parse function-strict-no-getter-setter-duplicate
+ "'use strict';\nvar a = {get x() {}, set x() {}};")
+
;;; Spread operator
(js2-deftest-parse spread-in-array-literal
- [elpa] master updated (7a2deff -> 04f3d4b), Dmitry Gutov, 2016/06/22
- [elpa] master f85abdd 005/110: Fix docstring to conform to the Elisp guideline, Dmitry Gutov, 2016/06/22
- [elpa] master b035bd0 006/110: Extract contextual keyword highlighting process from a predicate function, Dmitry Gutov, 2016/06/22
- [elpa] master cef7731 016/110: Handle open-curlies after newline, Dmitry Gutov, 2016/06/22
- [elpa] master 84379dd 004/110: Treat async/await as contextual keywords; Refs #185, Dmitry Gutov, 2016/06/22
- [elpa] master a2be944 014/110: Add a test for the latest change, Dmitry Gutov, 2016/06/22
- [elpa] master 34245fe 008/110: Don't treat getter / setter pairs as duplicates,
Dmitry Gutov <=
- [elpa] master fb3f5b6 010/110: Fix 'make all' on older emacsen, Dmitry Gutov, 2016/06/22
- [elpa] master 37867af 020/110: Add NEWS entry about rename to method-node, Dmitry Gutov, 2016/06/22
- [elpa] master b904d10 023/110: Merge pull request #279 from XeCycle/class-semicolon-elem, Dmitry Gutov, 2016/06/22
- [elpa] master 8abf087 025/110: Report error for binding initializer outside destructuring, Dmitry Gutov, 2016/06/22
- [elpa] master 4c0408b 032/110: Add NEWS entry for js2-jsx-mode, Dmitry Gutov, 2016/06/22
- [elpa] master bfb83dd 017/110: Refactor: unify computed property name handling, Dmitry Gutov, 2016/06/22
- [elpa] master c63c700 029/110: Update MELPA URL, Dmitry Gutov, 2016/06/22
- [elpa] master a28a648 007/110: Remove await-node for 'awayt' and use unary-node, Dmitry Gutov, 2016/06/22
- [elpa] master 2cf52e9 015/110: js2-parse-highlight-prop-get: Take care now to overwrite the js2-function-call face, Dmitry Gutov, 2016/06/22
- [elpa] master 3603bc4 018/110: Add test on shorthand method name and scoping, Dmitry Gutov, 2016/06/22