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

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

[elpa] master ee17084 13/45: js2-parse-plain-property: Disallow numbers


From: Dmitry Gutov
Subject: [elpa] master ee17084 13/45: js2-parse-plain-property: Disallow numbers as abbreviated props
Date: Mon, 02 Feb 2015 03:18:37 +0000

branch: master
commit ee17084c940b5d032355c832758696771aa81d7e
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    js2-parse-plain-property: Disallow numbers as abbreviated props
---
 js2-mode.el     |    3 ++-
 tests/parser.el |    3 +++
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/js2-mode.el b/js2-mode.el
index b150bb7..4ffb4d3 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -9788,7 +9788,8 @@ PROP is the node representing the property:  a number, 
name or string."
      ;; Abbreviated property, as in {foo, bar}
      ((and (>= js2-language-version 200)
            (or (= tt js2-COMMA)
-               (= tt js2-RC)))
+               (= tt js2-RC))
+           (not (js2-number-node-p prop)))
       (js2-unget-token)
       (setq result (make-js2-object-prop-node
                     :pos pos
diff --git a/tests/parser.el b/tests/parser.el
index d986ffc..ade10d8 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -184,6 +184,9 @@ the test."
 (js2-deftest-parse object-literal-shorthand
   "var x = {a: 1, b, c: 1, d};")
 
+(js2-deftest-parse object-literal-shorthard-with-number
+  "var a = {1};" :syntax-error ";" :errors-count 2)
+
 (js2-deftest-parse object-literal-method
   "var x = {f(y) {  return y;\n}};")
 



reply via email to

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