Skip to content

Commit 4f17ba1

Browse files
committed
null coalesce operator should be right-associative
1 parent 60c9d91 commit 4f17ba1

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

test/snapshot/__snapshots__/bin.test.js.snap

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,41 @@ Program {
561561
}
562562
`;
563563

564+
exports[`bin ?? right-associative 1`] = `
565+
Program {
566+
"children": Array [
567+
ExpressionStatement {
568+
"expression": Bin {
569+
"kind": "bin",
570+
"left": Bin {
571+
"kind": "bin",
572+
"left": Variable {
573+
"curly": false,
574+
"kind": "variable",
575+
"name": "foo",
576+
},
577+
"right": Variable {
578+
"curly": false,
579+
"kind": "variable",
580+
"name": "bar",
581+
},
582+
"type": "??",
583+
},
584+
"right": Variable {
585+
"curly": false,
586+
"kind": "variable",
587+
"name": "bazz",
588+
},
589+
"type": "??",
590+
},
591+
"kind": "expressionstatement",
592+
},
593+
],
594+
"errors": Array [],
595+
"kind": "program",
596+
}
597+
`;
598+
564599
exports[`bin ^ 1`] = `
565600
Program {
566601
"children": Array [

test/snapshot/bin.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ describe("bin", () => {
103103
it("??", () => {
104104
expect(parser.parseEval("$foo ?? $bar;")).toMatchSnapshot();
105105
});
106+
it("?? right-associative", () => {
107+
expect(parser.parseEval("$foo ?? $bar ?? $bazz;")).toMatchSnapshot();
108+
});
106109
it("?? (php < 7)", function() {
107110
const astErr = parser.parseEval(`$var ?? $var;`, {
108111
parser: {

0 commit comments

Comments
 (0)