diff --git a/.gitignore b/.gitignore index 4dfb35cc7a..8fed22464f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ coverage lib node_modules npm-debug.log +.vscode diff --git a/ast/spec.md b/ast/spec.md index 4a13d6d697..644f4af81b 100644 --- a/ast/spec.md +++ b/ast/spec.md @@ -791,7 +791,6 @@ enum BinaryOperator { | "|" | "^" | "&" | "in" | "instanceof" | "|>" - | "??" } ``` @@ -839,7 +838,7 @@ A logical operator expression. ```js enum LogicalOperator { - "||" | "&&" + "||" | "&&" | "??" } ``` diff --git a/src/parser/expression.js b/src/parser/expression.js index b44122514c..bc192cb491 100644 --- a/src/parser/expression.js +++ b/src/parser/expression.js @@ -311,7 +311,9 @@ export default class ExpressionParser extends LValParser { this.finishNode( node, - op === tt.logicalOR || op === tt.logicalAND + op === tt.logicalOR || + op === tt.logicalAND || + op === tt.nullishCoalescing ? "LogicalExpression" : "BinaryExpression", ); diff --git a/test/fixtures/experimental/nullish-coalescing-operator/associativity/expected.json b/test/fixtures/experimental/nullish-coalescing-operator/associativity/expected.json index 45384c754d..ccd1317f1a 100644 --- a/test/fixtures/experimental/nullish-coalescing-operator/associativity/expected.json +++ b/test/fixtures/experimental/nullish-coalescing-operator/associativity/expected.json @@ -43,7 +43,7 @@ } }, "expression": { - "type": "BinaryExpression", + "type": "LogicalExpression", "start": 0, "end": 11, "loc": { @@ -57,7 +57,7 @@ } }, "left": { - "type": "BinaryExpression", + "type": "LogicalExpression", "start": 0, "end": 6, "loc": { diff --git a/test/fixtures/experimental/nullish-coalescing-operator/expression/expected.json b/test/fixtures/experimental/nullish-coalescing-operator/expression/expected.json index 9e85e6f302..7a2f321c7c 100644 --- a/test/fixtures/experimental/nullish-coalescing-operator/expression/expected.json +++ b/test/fixtures/experimental/nullish-coalescing-operator/expression/expected.json @@ -43,7 +43,7 @@ } }, "expression": { - "type": "BinaryExpression", + "type": "LogicalExpression", "start": 0, "end": 8, "loc": { diff --git a/test/fixtures/experimental/nullish-coalescing-operator/multiline/expected.json b/test/fixtures/experimental/nullish-coalescing-operator/multiline/expected.json index 99f325b056..3043dfb4b7 100644 --- a/test/fixtures/experimental/nullish-coalescing-operator/multiline/expected.json +++ b/test/fixtures/experimental/nullish-coalescing-operator/multiline/expected.json @@ -43,7 +43,7 @@ } }, "expression": { - "type": "BinaryExpression", + "type": "LogicalExpression", "start": 0, "end": 16, "loc": { @@ -57,7 +57,7 @@ } }, "left": { - "type": "BinaryExpression", + "type": "LogicalExpression", "start": 0, "end": 9, "loc": { diff --git a/test/fixtures/experimental/nullish-coalescing-operator/precedence-high/expected.json b/test/fixtures/experimental/nullish-coalescing-operator/precedence-high/expected.json index 9ac8a339b0..57817930c4 100644 --- a/test/fixtures/experimental/nullish-coalescing-operator/precedence-high/expected.json +++ b/test/fixtures/experimental/nullish-coalescing-operator/precedence-high/expected.json @@ -75,7 +75,7 @@ }, "operator": "|>", "right": { - "type": "BinaryExpression", + "type": "LogicalExpression", "start": 5, "end": 11, "loc": { diff --git a/test/fixtures/experimental/nullish-coalescing-operator/precedence-low/expected.json b/test/fixtures/experimental/nullish-coalescing-operator/precedence-low/expected.json index 57c4decc9f..57882d871e 100644 --- a/test/fixtures/experimental/nullish-coalescing-operator/precedence-low/expected.json +++ b/test/fixtures/experimental/nullish-coalescing-operator/precedence-low/expected.json @@ -43,7 +43,7 @@ } }, "expression": { - "type": "BinaryExpression", + "type": "LogicalExpression", "start": 0, "end": 11, "loc": {