Skip to content

Commit 535a47b

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

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎src/parser/class.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,10 @@ 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 if not already set
446+
if (result[0][0] === -1) {
447+
result[0][0] = 0;
448+
}
445449
this.next(); // consume '('
446450
if (this.token !== this.tok.T_STRING || this.text() !== "set") {
447451
this.error("set");

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

Lines changed: 2 additions & 2 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
],
@@ -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)