Skip to content

Commit 1218fbf

Browse files
committed
fix: default read visibility to public for shorthand asymmetric syntax
1 parent bde1d64 commit 1218fbf

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/parser/class.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,8 @@ module.exports = {
442442
this.next(); // consume the visibility keyword
443443
if (this.version >= 804 && this.token === "(") {
444444
// visibility(set) modifier: e.g. private(set)
445+
// For shorthand, default get visibility to public
446+
result[0][0] = 0;
445447
this.next(); // consume '('
446448
if (this.token !== this.tok.T_STRING || this.text() !== "set") {
447449
this.error("set");

test/snapshot/__snapshots__/asymmetric-visibility.test.js.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ Program {
12071207
"value": null,
12081208
},
12091209
],
1210-
"visibility": "",
1210+
"visibility": "public",
12111211
"visibilitySet": "private",
12121212
},
12131213
],
@@ -1259,7 +1259,7 @@ Program {
12591259
"value": null,
12601260
},
12611261
],
1262-
"visibility": "protected",
1262+
"visibility": "public",
12631263
"visibilitySet": "private",
12641264
},
12651265
],
@@ -1311,7 +1311,7 @@ Program {
13111311
"value": null,
13121312
},
13131313
],
1314-
"visibility": "",
1314+
"visibility": "public",
13151315
"visibilitySet": "protected",
13161316
},
13171317
],

0 commit comments

Comments
 (0)