[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master f1edac7 19/33: Don't treat a block-scoped const as redecla
From: |
Dmitry Gutov |
Subject: |
[elpa] master f1edac7 19/33: Don't treat a block-scoped const as redeclaration |
Date: |
Sun, 12 Jul 2015 22:35:42 +0000 |
branch: master
commit f1edac7db39c7ef433f9d597c71014a90fd61488
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Don't treat a block-scoped const as redeclaration
---
js2-mode.el | 8 ++++++--
tests/parser.el | 8 +++++---
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/js2-mode.el b/js2-mode.el
index 18cda80..5745dc5 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -9559,8 +9559,12 @@ If NODE is non-nil, it is the AST node associated with
the symbol."
(len (if node (js2-node-len node))))
(cond
((and symbol ; already defined
- (or (= sdt js2-CONST) ; old version is const
- (= decl-type js2-CONST) ; new version is const
+ (or (if js2-in-use-strict-directive
+ ;; two const-bound vars in this block have same name
+ (and (= sdt js2-CONST)
+ (eq defining-scope js2-current-scope))
+ (or (= sdt js2-CONST) ; old version is const
+ (= decl-type js2-CONST))) ; new version is const
;; two let-bound vars in this block have same name
(and (= sdt js2-LET)
(eq defining-scope js2-current-scope))))
diff --git a/tests/parser.el b/tests/parser.el
index 93c47ab..b9c9c68 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -247,7 +247,7 @@ the test."
(js2-deftest-parse function-with-rest-after-default-parameter
"function foo(a = 1, ...rest) {\n}")
-;;; Strict identifiers
+;;; Strict mode errors
(js2-deftest-parse function-bad-strict-parameters
"'use strict';\nfunction foo(eval, {arguments}, bar) {\n}"
@@ -281,8 +281,6 @@ the test."
"'use strict';\narguments = 'fufufu';"
:syntax-error "arguments" :errors-count 1)
-;;; Strict syntax errors
-
(js2-deftest-parse function-strict-with
"'use strict';\nwith ({}) {}"
:syntax-error "with" :errors-count 1)
@@ -295,6 +293,10 @@ 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-const-scope
+ "'use strict';\nconst a;\nif (1) {\n const a;\n}")
+
;;; Spread operator
(js2-deftest-parse spread-in-array-literal
- [elpa] master 1277c7d 12/33: Track script and function strict mode., (continued)
- [elpa] master 1277c7d 12/33: Track script and function strict mode., Dmitry Gutov, 2015/07/12
- [elpa] master 498bcca 21/33: Fix refactoring regression., Dmitry Gutov, 2015/07/12
- [elpa] master 663efb1 24/33: Remove strict mode slots on nodes., Dmitry Gutov, 2015/07/12
- [elpa] master 6255edb 18/33: Cleanup, Dmitry Gutov, 2015/07/12
- [elpa] master ad4c5cc 20/33: Report the correct octal number error, Dmitry Gutov, 2015/07/12
- [elpa] master ac205a4 16/33: Octal syntax is an error in strict mode, Dmitry Gutov, 2015/07/12
- [elpa] master 7850d12 25/33: Cleanup, Dmitry Gutov, 2015/07/12
- [elpa] master e6cb7bf 15/33: with statements are syntax errors in strict mode, Dmitry Gutov, 2015/07/12
- [elpa] master 46e1492 23/33: Reparse strict functions., Dmitry Gutov, 2015/07/12
- [elpa] master 1391f2e 22/33: setq inline, Dmitry Gutov, 2015/07/12
- [elpa] master f1edac7 19/33: Don't treat a block-scoped const as redeclaration,
Dmitry Gutov <=
- [elpa] master c588e31 17/33: Duplicate object keys are an error in strict mode, Dmitry Gutov, 2015/07/12
- [elpa] master 2469440 26/33: Fix bug where properties where checked for strict mode compliance, Dmitry Gutov, 2015/07/12
- [elpa] master 12e5a21 28/33: Remove js2-current-indent, Dmitry Gutov, 2015/07/12
- [elpa] master 5b25da2 30/33: Add NEWS entry and bump version, Dmitry Gutov, 2015/07/12
- [elpa] master e0ecf99 14/33: Check identifiers in strict mode., Dmitry Gutov, 2015/07/12
- [elpa] master f3a899b 32/33: And actually update NEWS, Dmitry Gutov, 2015/07/12
- [elpa] master 53f3f52 31/33: Actually remove the macro, Dmitry Gutov, 2015/07/12
- [elpa] master eb33e68 29/33: Get rid of js2-with-underscore-as-word-syntax, Dmitry Gutov, 2015/07/12
- [elpa] master 5e5df54 27/33: Merge pull request #242 from jacksonrayhamilton/strict-mode, Dmitry Gutov, 2015/07/12
- [elpa] master 2763c9a 33/33: Merge commit 'f3a899bb1c36e25e078eed2890eb2fecb22f4175' from js2-mode, Dmitry Gutov, 2015/07/12