This is specified by the ComputedPropertyName production in ยง12.2.5 of the draft ES6 spec: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object-initializer, and discussed at https://github.com/lukehoban/es6features\#enhanced-object-literals.
(js2-msg "msg.yield.closing"
"Yield from closing generator")
+;; Classes
+(js2-msg "msg.missing.computed.rb" ; added by js2-mode
+ "missing ']' after computed property expression")
+
;;; Tokens Buffer
(defconst js2-ti-max-lookahead 2)
(not js2-recover-from-parse-errors))
(setq continue nil)
(push result elems)))
+ ;; {[Symbol.iterator]: ...}
+ ((and (= tt js2-LB)
+ (>= js2-language-version 200))
+ (let ((expr (js2-parse-expr)))
+ (js2-must-match js2-RB "msg.missing.computed.rb")
+ (setq after-comma nil)
+ (push (js2-parse-plain-property expr) elems)))
;; {12: x} or {10.7: x}
((= tt js2-NUMBER)
(setq after-comma nil)
;;; Object literals
-(js2-deftest-parse abbreviated-object
+(js2-deftest-parse object-literal-shorthand
"var x = {a: 1, b, c: 1, d};")
(js2-deftest-parse object-literal-method
(js2-deftest-parse object-literal-setter-method
"var x = {set f(y) { x = y;\n}};")
+(js2-deftest-parse object-literal-computed-keys
+ "var x = {[Symbol.iterator]: function() {}};")
+
;;; Function parameters
(js2-deftest-parse function-with-default-parameters