[gtksourceview: 5/13] javascript.lang: Fix comma operator inside ternary operator
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview: 5/13] javascript.lang: Fix comma operator inside ternary operator
- Date: Tue, 2 Jun 2020 18:34:56 +0000 (UTC)
commit b70bd732eb55a1aa90703ad00e62d63b133e9090
Author: Jeffery To <jeffery to gmail com>
Date: Sun Jan 19 18:42:50 2020 +0800
javascript.lang: Fix comma operator inside ternary operator
The comma operator is not allowed inside the true expression of the
ternary operator, even when commas are allowed in the surrounding
expression.
data/language-specs/javascript-expressions.lang | 2 +-
tests/syntax-highlighting/file.j | 1 +
tests/syntax-highlighting/file.js | 1 +
tests/syntax-highlighting/file.jsx | 1 +
tests/syntax-highlighting/file.ts | 1 +
tests/syntax-highlighting/file.tsx | 1 +
6 files changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/data/language-specs/javascript-expressions.lang b/data/language-specs/javascript-expressions.lang
index 561807cb..57a27972 100644
--- a/data/language-specs/javascript-expressions.lang
+++ b/data/language-specs/javascript-expressions.lang
@@ -560,7 +560,7 @@
<context id="_ternary-operator-with-comma-true-expression-content">
<include>
- <context ref="expression-with-comma"/>
+ <context ref="expression-without-comma"/> <!-- comma not allowed -->
<context ref="_ternary-operator-with-comma-false-expression"/>
</include>
</context> <!-- /_ternary-operator-with-comma-true-expression-content -->
diff --git a/tests/syntax-highlighting/file.j b/tests/syntax-highlighting/file.j
index 44e23f3b..89f0dd72 100644
--- a/tests/syntax-highlighting/file.j
+++ b/tests/syntax-highlighting/file.j
@@ -791,6 +791,7 @@ a = class extends Bar {
// Conditional / ternary
( true ? 1 : 2 );
( true ? : 2 ); // missing true value (syntax error)
+obj[ true ? 1, 2 : 3 ]; // comma operator inside true expression (syntax error)
/*
diff --git a/tests/syntax-highlighting/file.js b/tests/syntax-highlighting/file.js
index 2239bf4f..4a238bcf 100644
--- a/tests/syntax-highlighting/file.js
+++ b/tests/syntax-highlighting/file.js
@@ -490,6 +490,7 @@ a = class extends Bar {
// Conditional / ternary
( true ? 1 : 2 );
( true ? : 2 ); // missing true value (syntax error)
+obj[ true ? 1, 2 : 3 ]; // comma operator inside true expression (syntax error)
/*
diff --git a/tests/syntax-highlighting/file.jsx b/tests/syntax-highlighting/file.jsx
index 289f0bdf..bd59d6b0 100644
--- a/tests/syntax-highlighting/file.jsx
+++ b/tests/syntax-highlighting/file.jsx
@@ -547,6 +547,7 @@ a = class extends Bar {
// Conditional / ternary
( true ? 1 : 2 );
( true ? : 2 ); // missing true value (syntax error)
+obj[ true ? 1, 2 : 3 ]; // comma operator inside true expression (syntax error)
/*
diff --git a/tests/syntax-highlighting/file.ts b/tests/syntax-highlighting/file.ts
index cb87b65e..199aac48 100644
--- a/tests/syntax-highlighting/file.ts
+++ b/tests/syntax-highlighting/file.ts
@@ -1084,6 +1084,7 @@ a = class extends Bar {
// Conditional / ternary
( true ? 1 : 2 );
( true ? : 2 ); // missing true value (syntax error)
+obj[ true ? 1, 2 : 3 ]; // comma operator inside true expression (syntax error)
/*
diff --git a/tests/syntax-highlighting/file.tsx b/tests/syntax-highlighting/file.tsx
index 84387a96..b63955c7 100644
--- a/tests/syntax-highlighting/file.tsx
+++ b/tests/syntax-highlighting/file.tsx
@@ -1192,6 +1192,7 @@ a = class extends Bar {
// Conditional / ternary
( true ? 1 : 2 );
( true ? : 2 ); // missing true value (syntax error)
+obj[ true ? 1, 2 : 3 ]; // comma operator inside true expression (syntax error)
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]