[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/js2-mode db17df4 53/61: Fix nullish coalescing in cond
From: |
Dmitry Gutov |
Subject: |
[elpa] externals/js2-mode db17df4 53/61: Fix nullish coalescing in cond exprs and add test with ternary op |
Date: |
Sun, 20 Dec 2020 12:20:11 -0500 (EST) |
branch: externals/js2-mode
commit db17df4670355c6b27dfed13959d8da442a154ed
Author: Jonathan Ming <jming422@gmail.com>
Commit: Jonathan Ming <jming422@gmail.com>
Fix nullish coalescing in cond exprs and add test with ternary op
---
js2-mode.el | 10 +++++-----
tests/parser.el | 13 +++++++------
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/js2-mode.el b/js2-mode.el
index 341f01b..fae3b5f 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -9938,7 +9938,7 @@ If NODE is non-nil, it is the AST node associated with
the symbol."
(defun js2-parse-cond-expr ()
(let ((pos (js2-current-token-beg))
- (pn (js2-parse-nullish-coalescing-expr))
+ (pn (js2-parse-or-expr))
test-expr
if-true
if-false
@@ -10016,7 +10016,7 @@ FIXME: The latter option is unused?"
pn))
(defun js2-parse-bit-and-expr ()
- (let ((pn (js2-parse-eq-expr)))
+ (let ((pn (js2-parse-nullish-coalescing-expr)))
(while (js2-match-token js2-BITAND)
(setq pn (js2-make-binary js2-BITAND
pn
@@ -10025,12 +10025,12 @@ FIXME: The latter option is unused?"
(defun js2-parse-nullish-coalescing-expr ()
- (let ((pn (js2-parse-or-expr)))
+ (let ((pn (js2-parse-eq-expr)))
(when (js2-match-token js2-NULLISH-COALESCING)
(setq pn (js2-make-binary js2-NULLISH-COALESCING
pn
- 'js2-parse-nullish-coalescing-expr)))
- pn))
+ 'js2-parse-nullish-coalescing-expr))
+ pn)))
(defconst js2-parse-eq-ops
(list js2-EQ js2-NE js2-SHEQ js2-SHNE))
diff --git a/tests/parser.el b/tests/parser.el
index 4fa1950..952aa35 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -997,18 +997,19 @@ the test."
;; nullish coalescing, via https://github.com/tc39/proposal-nullish-coalescing
(js2-deftest-parse nullish-coalescing-operator-null-variable
- "var a = null; a ?? 1;")
+ "var a = null;\na ?? 1;")
(js2-deftest-parse nullish-coalescing-operator-inexisting-field
- "var a = {}; a.nonexistant ?? 1;")
+ "var a = {};\na.nonexistant ?? 1;")
(js2-deftest-parse nullish-coalescing-operator-null-value
- "var b = 1; null ?? b;")
+ "var b = 1;\nnull ?? b;")
(js2-deftest-parse nullish-coalescing-operator-in-if
- "if (null ?? b) {
- return null;
-}")
+ "if (null ?? true) {\n a = 2;\n}")
+
+(js2-deftest-parse nullish-coalescing-operator-in-ternary
+ "var c = null ?? true ? 1 : 2;")
(js2-deftest optional-chaining-operator-on-property-access
- [elpa] externals/js2-mode fe53814 26/61: Merge pull request #544 from wyuenho/use-type-face-for-class, (continued)
- [elpa] externals/js2-mode fe53814 26/61: Merge pull request #544 from wyuenho/use-type-face-for-class, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode e8bbfd2 31/61: Merge pull request #551 from phst/let, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode 710e430 33/61: Migrate remaining files to lexical binding, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode 124d4a3 35/61: Prefix an unused argument with an underscore., Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode c00a562 37/61: Add browser symbols from the jslint setup, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode d397cab 39/61: Merge pull request #553 from phst/lexical, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode ae2d021 40/61: Merge pull request #554 from phst/unused-var, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode 3afdc05 42/61: move HTML element constructors to specific section, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode df9d74e 46/61: Improve a comment, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode b4ede70 47/61: Fix &rest syntax in cl-destructuring-bind., Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode db17df4 53/61: Fix nullish coalescing in cond exprs and add test with ternary op,
Dmitry Gutov <=
- [elpa] externals/js2-mode c665ebe 55/61: Move '??' back between '?:' and '||', Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode 7f4ada4 49/61: start implementing NULLISH-COALESCING, likely incomplete, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode ffb7099 58/61: Merge pull request #563 from KevinBoyette/update-readme, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode 90e1434 48/61: Merge pull request #558 from phst/edebug, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode eb3be7e 54/61: Fix misplaced paren, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode c1763ab 52/61: add failing tests, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode 0f627a4 57/61: Update README.md, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode 6740d34 50/61: fix tokencount + structure, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode f956476 60/61: Release new version, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode f7816bd 59/61: Support logical assignment operators, Dmitry Gutov, 2020/12/20