(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))
(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