[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master ab82544 23/45: Do not declare fn expression's name in the
From: |
Dmitry Gutov |
Subject: |
[elpa] master ab82544 23/45: Do not declare fn expression's name in the enclosing scope |
Date: |
Mon, 02 Feb 2015 03:18:42 +0000 |
branch: master
commit ab825444356826caf4d85ee60c452de2975eb5a2
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Do not declare fn expression's name in the enclosing scope
Fixes #186
---
js2-mode.el | 3 ++-
tests/parser.el | 10 ++++++++++
2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/js2-mode.el b/js2-mode.el
index c3bb903..b80d60d 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -7664,7 +7664,8 @@ arrow function), NAME is js2-name-node."
(when name
(js2-set-face (js2-node-pos name) (js2-node-end name)
'font-lock-function-name-face 'record)
- (when (plusp (js2-name-node-length name))
+ (when (and (eq function-type 'FUNCTION_STATEMENT)
+ (plusp (js2-name-node-length name)))
;; Function statements define a symbol in the enclosing scope
(js2-define-symbol js2-FUNCTION (js2-name-node-name name) fn-node)))
(if (or (js2-inside-function) (plusp js2-nesting-of-with))
diff --git a/tests/parser.el b/tests/parser.el
index dc210a5..00bd2cf 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -199,6 +199,16 @@ the test."
(js2-deftest-parse object-literal-computed-keys
"var x = {[Symbol.iterator]: function() {}};")
+;;; Function definition
+
+(js2-deftest function-redeclaring-var "var gen = 3; function gen() {};"
+ (js2-mode)
+ (should (= (length (js2-ast-root-warnings js2-mode-ast)) 1)))
+
+(js2-deftest function-expression-var-same-name "var gen = function gen() {};"
+ (js2-mode)
+ (should (null (js2-ast-root-warnings js2-mode-ast))))
+
;;; Function parameters
(js2-deftest-parse function-with-default-parameters
- [elpa] master 31c49e0 14/45: js2-imenu-extension-styles: Turn into defvar, (continued)
- [elpa] master 31c49e0 14/45: js2-imenu-extension-styles: Turn into defvar, Dmitry Gutov, 2015/02/01
- [elpa] master 9b77d64 15/45: Implement template strings, ignoring substitutions, Dmitry Gutov, 2015/02/01
- [elpa] master 7b3d590 17/45: No need to explicitly apply face to string nodes, Dmitry Gutov, 2015/02/01
- [elpa] master 3f09ff3 09/45: Fix string literals in parser.el test harness., Dmitry Gutov, 2015/02/01
- [elpa] master d0c6bf3 18/45: Comment the new token types, Dmitry Gutov, 2015/02/01
- [elpa] master 9525eb3 10/45: Merge branch 'master' of github.com:shicks/js2-mode into shicks-master, Dmitry Gutov, 2015/02/01
- [elpa] master c910d1b 19/45: Parse tagged templates, Dmitry Gutov, 2015/02/01
- [elpa] master 8df508e 16/45: Handle template substitutions, Dmitry Gutov, 2015/02/01
- [elpa] master 92063fe 22/45: Fix js2-visit-tagged-template, Dmitry Gutov, 2015/02/01
- [elpa] master 94c2ec9 20/45: Drop `js2-allow-keywords-as-property-names' and `js2-valid-prop-name-token', Dmitry Gutov, 2015/02/01
- [elpa] master ab82544 23/45: Do not declare fn expression's name in the enclosing scope,
Dmitry Gutov <=
- [elpa] master e6dc986 24/45: Limit the scope of `with-silent-modifications', Dmitry Gutov, 2015/02/01
- [elpa] master 6a4e84b 26/45: js2-parse-for: Reword docstring and comments, Dmitry Gutov, 2015/02/01
- [elpa] master 8088e75 21/45: Add js2-language-version check for template literals, Dmitry Gutov, 2015/02/01
- [elpa] master 395d4ae 29/45: Highlight methods with font-lock-function-name-face, Dmitry Gutov, 2015/02/01
- [elpa] master a117465 32/45: Handle "arguments" specially, Dmitry Gutov, 2015/02/01
- [elpa] master 3c4367f 25/45: Make catch-node inherit from scope, Dmitry Gutov, 2015/02/01
- [elpa] master 65bd910 35/45: `js2-time' remove unused variable., Dmitry Gutov, 2015/02/01
- [elpa] master e109213 36/45: Merge pull request #203 from cheunghy/master, Dmitry Gutov, 2015/02/01
- [elpa] master b0ea681 33/45: Add animationFrame functions, Dmitry Gutov, 2015/02/01
- [elpa] master 590db34 37/45: js2-parse-class-stmt: Define the class in the current scope, Dmitry Gutov, 2015/02/01