emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 926cb45 05/45: Support ES6 computed property names.


From: Dmitry Gutov
Subject: [elpa] master 926cb45 05/45: Support ES6 computed property names.
Date: Mon, 02 Feb 2015 03:18:33 +0000

branch: master
commit 926cb455eca15f05264d2b0192e96de28d1ba986
Author: Stephen Hicks <address@hidden>
Commit: Stephen Hicks <address@hidden>

    Support ES6 computed property names.
    
    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-mode.el     |   11 +++++++++++
 tests/parser.el |    5 ++++-
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/js2-mode.el b/js2-mode.el
index 33d45bd..c53c5b6 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -1955,6 +1955,10 @@ the correct number of ARGS must be provided."
 (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)
@@ -9554,6 +9558,13 @@ If ONLY-OF-P is non-nil, only the 'for (foo of bar)' 
form is allowed."
                  (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)
diff --git a/tests/parser.el b/tests/parser.el
index 3804ce8..fe66d36 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -181,7 +181,7 @@ the test."
 
 ;;; 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
@@ -193,6 +193,9 @@ the test."
 (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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]