[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 26/46: Allow 'in' operator inside 'for' init when unambiguous
From: |
Dmitry Gutov |
Subject: |
[elpa] 26/46: Allow 'in' operator inside 'for' init when unambiguous |
Date: |
Sat, 15 Nov 2014 20:58:05 +0000 |
dgutov pushed a commit to branch master
in repository elpa.
commit aef2c811ac24750ea8a923708eddf82a1f34bd26
Author: Dmitry Gutov <address@hidden>
Date: Mon Aug 4 07:31:02 2014 +0400
Allow 'in' operator inside 'for' init when unambiguous
Fixes #155
---
js2-mode.el | 5 +++--
tests/parser.el | 6 ++++++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/js2-mode.el b/js2-mode.el
index e939258..62a9da4 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -8535,7 +8535,8 @@ If NODE is non-nil, it is the AST node associated with
the symbol."
(if (and (>= js2-language-version 200)
(js2-match-token js2-FOR))
(js2-parse-generator-comp px-pos)
- (let* ((expr (js2-parse-expr))
+ (let* ((js2-in-for-init nil)
+ (expr (js2-parse-expr))
(pn (make-js2-paren-node :pos px-pos
:expr expr
:len (- (js2-current-token-end)
@@ -8617,7 +8618,7 @@ If NODE is non-nil, it is the AST node associated with
the symbol."
c-pos)
(when (js2-match-token js2-HOOK)
(setq q-pos (- (js2-current-token-beg) pos)
- if-true (js2-parse-assign-expr))
+ if-true (let (js2-in-for-init) (js2-parse-assign-expr)))
(js2-must-match js2-COLON "msg.no.colon.cond")
(setq c-pos (- (js2-current-token-beg) pos)
if-false (js2-parse-assign-expr)
diff --git a/tests/parser.el b/tests/parser.el
index 2e492a2..389d686 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -115,6 +115,12 @@ the test."
(js2-deftest-parse parenthesized-expression
"(1 + 2);")
+(js2-deftest-parse for-with-in-operator-in-parens
+ "for (var y = (0 in []) in {}) {\n}")
+
+(js2-deftest-parse for-with-in-operator-in-cond
+ "for (var y = 1 ? 0 in [] : false in {}) {\n}")
+
;;; Callers of `js2-valid-prop-name-token'
(js2-deftest-parse parse-property-access-when-not-keyword
- [elpa] 16/46: Support Unicode Identifiers, (continued)
- [elpa] 16/46: Support Unicode Identifiers, Dmitry Gutov, 2014/11/15
- [elpa] 17/46: Check if buffer is alive before reparsing., Dmitry Gutov, 2014/11/15
- [elpa] 19/46: Better docstrings, Dmitry Gutov, 2014/11/15
- [elpa] 14/46: Support ES6 generator comprehensions, Dmitry Gutov, 2014/11/15
- [elpa] 13/46: Support ES6 array comprehensions, Dmitry Gutov, 2014/11/15
- [elpa] 12/46: Add `.' to electric-indent-chars for method continuations, Dmitry Gutov, 2014/11/15
- [elpa] 15/46: Add Contributing section, Dmitry Gutov, 2014/11/15
- [elpa] 24/46: Small tweak, Dmitry Gutov, 2014/11/15
- [elpa] 23/46: Add js2-language-version checks, Dmitry Gutov, 2014/11/15
- [elpa] 25/46: Ignore integer overflow, Dmitry Gutov, 2014/11/15
- [elpa] 26/46: Allow 'in' operator inside 'for' init when unambiguous,
Dmitry Gutov <=
- [elpa] 27/46: Fix parsing of let expressions, Dmitry Gutov, 2014/11/15
- [elpa] 18/46: Merge pull request #149 from lewang/dont-parse-killed-buffer, Dmitry Gutov, 2014/11/15
- [elpa] 28/46: js2-parse-let: Simplify, Dmitry Gutov, 2014/11/15
- [elpa] 22/46: Support ES6 number literals, Dmitry Gutov, 2014/11/15
- [elpa] 21/46: js2-get-token-internal-1: add a FIXME, Dmitry Gutov, 2014/11/15
- [elpa] 20/46: js2-read-unicode-escape: use a stricter regexp, Dmitry Gutov, 2014/11/15
- [elpa] 29/46: Fontify negation operator, Dmitry Gutov, 2014/11/15
- [elpa] 32/46: Fix #171, Dmitry Gutov, 2014/11/15
- [elpa] 31/46: js2-mode-find-enclosing-node: Make docstring and impl consistent with name, Dmitry Gutov, 2014/11/15
- [elpa] 33/46: js2-parse-primary-expr: Make some vars "more" local, Dmitry Gutov, 2014/11/15