This reports error for both object literals and class bodies, but only
tests object literals; because if ES7 class property initializers are
added, the error no longer makes sense and needs another message,
e.g. missing semicolon after property initializer.
(js2-msg "msg.destruct.assign.no.init"
"Missing = in destructuring declaration")
+(js2-msg "msg.init.no.destruct"
+ "Binding initializer not in destructuring assignment")
+
(js2-msg "msg.no.octal.strict"
"Octal numbers prohibited in strict mode.")
;; binding element with initializer
((and (= (js2-peek-token) js2-ASSIGN)
(>= js2-language-version 200))
+ (if (not js2-is-in-destructuring)
+ (js2-report-error "msg.init.no.destruct"))
(js2-parse-initialized-binding key))
;; regular prop
(t
(should (equal '("msg.var.redecl" "a")
(caar js2-parsed-warnings))))
+(js2-deftest initializer-outside-destruct-is-error "({a=1});"
+ (js2-mode)
+ (should (equal "msg.init.no.destruct"
+ (car (caar js2-parsed-errors)))))
+
;;; Object literals
(js2-deftest-parse object-literal-shorthand