[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 66fe8de 107/110: js2-define-symbol: Treat const same as le
From: |
Dmitry Gutov |
Subject: |
[elpa] master 66fe8de 107/110: js2-define-symbol: Treat const same as let |
Date: |
Thu, 23 Jun 2016 01:13:04 +0000 (UTC) |
branch: master
commit 66fe8de8e9b0ac501d29c613f365353262868eb5
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
js2-define-symbol: Treat const same as let
Fixes #306
---
js2-mode.el | 23 ++++++-----------------
tests/parser.el | 14 ++------------
2 files changed, 8 insertions(+), 29 deletions(-)
diff --git a/js2-mode.el b/js2-mode.el
index a46423e..ba492d7 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -9610,16 +9610,10 @@ If NODE is non-nil, it is the AST node associated with
the symbol."
(pos (if node (js2-node-abs-pos node)))
(len (if node (js2-node-len node))))
(cond
- ((and symbol ; already defined
- (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))))
+ ((and symbol ; already defined in this block
+ (or (= sdt js2-LET)
+ (= sdt js2-CONST))
+ (eq defining-scope js2-current-scope))
(js2-report-error
(cond
((= sdt js2-CONST) "msg.const.redecl")
@@ -9629,9 +9623,7 @@ If NODE is non-nil, it is the AST node associated with
the symbol."
(t "msg.parm.redecl"))
name pos len))
((or (= decl-type js2-LET)
- ;; strict mode const is scoped to the current LexicalEnvironment
- (and js2-in-use-strict-directive
- (= decl-type js2-CONST)))
+ (= decl-type js2-CONST))
(if (and (= decl-type js2-LET)
(not ignore-not-in-block)
(or (= (js2-node-type js2-current-scope) js2-IF)
@@ -9639,10 +9631,7 @@ If NODE is non-nil, it is the AST node associated with
the symbol."
(js2-report-error "msg.let.decl.not.in.block")
(js2-define-new-symbol decl-type name node)))
((or (= decl-type js2-VAR)
- (= decl-type js2-FUNCTION)
- ;; sloppy mode const is scoped to the current VariableEnvironment
- (and (not js2-in-use-strict-directive)
- (= decl-type js2-CONST)))
+ (= decl-type js2-FUNCTION))
(if symbol
(if (and js2-strict-var-redeclaration-warning (= sdt js2-VAR))
(js2-add-strict-warning "msg.var.redecl" name)
diff --git a/tests/parser.el b/tests/parser.el
index 9667e56..69222b8 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -968,22 +968,12 @@ the test."
(js2-mode--and-parse)
(js2-test-scope-of-nth-variable-satisifies-predicate "i" 0 #'js2-for-node-p))
-(js2-deftest const-scope-sloppy-script "{const a;} a;"
- (js2-mode--and-parse)
- (js2-test-scope-of-nth-variable-satisifies-predicate "a" 0
#'js2-script-node-p)
- (js2-test-scope-of-nth-variable-satisifies-predicate "a" 1
#'js2-script-node-p))
-
-(js2-deftest const-scope-strict-script "'use strict'; { const a; } a;"
+(js2-deftest const-scope-inside-script "{ const a; } a;"
(js2-mode--and-parse)
(js2-test-scope-of-nth-variable-satisifies-predicate "a" 0
#'js2-block-node-p)
(js2-test-scope-of-nth-variable-satisifies-predicate "a" 1 #'null))
-(js2-deftest const-scope-sloppy-function "function f() { { const a; } a; }"
- (js2-mode--and-parse)
- (js2-test-scope-of-nth-variable-satisifies-predicate "a" 0
#'js2-function-node-p)
- (js2-test-scope-of-nth-variable-satisifies-predicate "a" 1
#'js2-function-node-p))
-
-(js2-deftest const-scope-strict-function "function f() { 'use strict'; { const
a; } a; }"
+(js2-deftest const-scope-inside-function "function f() { { const a; } a; }"
(js2-mode--and-parse)
(js2-test-scope-of-nth-variable-satisifies-predicate "a" 0
#'js2-block-node-p)
(js2-test-scope-of-nth-variable-satisifies-predicate "a" 1 #'null))
- [elpa] master ec7932d 047/110: Merge pull request #283 from XeCycle/master-with-async, (continued)
- [elpa] master ec7932d 047/110: Merge pull request #283 from XeCycle/master-with-async, Dmitry Gutov, 2016/06/22
- [elpa] master e44d9e1 088/110: Merge pull request #325 from phst/all-tests, Dmitry Gutov, 2016/06/22
- [elpa] master 812df51 091/110: Merge pull request #326 from phst/compiler-warning-25, Dmitry Gutov, 2016/06/22
- [elpa] master de5b31c 085/110: Fix the tests broken in the previous commit, Dmitry Gutov, 2016/06/22
- [elpa] master f130121 095/110: Merge pull request #328 from XeCycle/iname-color, Dmitry Gutov, 2016/06/22
- [elpa] master 9586f45 096/110: Add :warnings-count keyword argument, Dmitry Gutov, 2016/06/22
- [elpa] master e5e4fa4 105/110: Add js2-mode-assume-strict custom variable, Dmitry Gutov, 2016/06/22
- [elpa] master bb0acf5 106/110: Merge pull request #342 from shicks/strict, Dmitry Gutov, 2016/06/22
- [elpa] master 173d1c8 101/110: Merge pull request #332 from bolivier/master, Dmitry Gutov, 2016/06/22
- [elpa] master c162f35 092/110: Colorize contextual keywords as & from in import & export, Dmitry Gutov, 2016/06/22
- [elpa] master 66fe8de 107/110: js2-define-symbol: Treat const same as let,
Dmitry Gutov <=
- [elpa] master 04f3d4b 110/110: Merge commit '0cda39255827f283e7578cd469ae42daad9556a2' from js2-mode, Dmitry Gutov, 2016/06/22