(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))))
(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}"
"'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)
"'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