Skip to content

Commit

Permalink
fix: allow identifiers to be modifier names
Browse files Browse the repository at this point in the history
  • Loading branch information
DonIsaac committed Jun 29, 2024
1 parent 845dda6 commit f2ba061
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 50 deletions.
2 changes: 1 addition & 1 deletion crates/oxc_parser/src/js/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl<'a> ParserImpl<'a> {
modifier_kind
if self.ts_enabled()
&& modifier_kind.is_modifier_kind()
&& !matches!(peek_kind, Kind::Colon) =>
&& peek_kind.is_identifier_or_keyword() =>
{
if let Ok(modifier) = Modifier::try_from(self.cur_token()) {
self.error(diagnostics::modifier_cannot_be_used_here(&modifier));
Expand Down
38 changes: 2 additions & 36 deletions tasks/coverage/parser_misc.snap
Original file line number Diff line number Diff line change
@@ -1,41 +1,7 @@
parser_misc Summary:
AST Parsed : 19/21 (90.48%)
Positive Passed: 19/21 (90.48%)
AST Parsed : 21/21 (100.00%)
Positive Passed: 21/21 (100.00%)
Negative Passed: 11/11 (100.00%)
Expect to Parse: "pass/oxc-2948-2.ts"

× 'readonly' modifier cannot be used here.
╭─[pass/oxc-2948-2.ts:18:13]
17
18const x = { readonly, override };
· ────────
19const y = { readonly: readonly, override: override };
╰────

× Unexpected token
╭─[pass/oxc-2948-2.ts:18:21]
17
18const x = { readonly, override };
· ─
19const y = { readonly: readonly, override: override };
╰────
Expect to Parse: "pass/oxc-3948-1.ts"

× 'accessor' modifier cannot be used here.
╭─[pass/oxc-3948-1.ts:107:12]
106
107return { accessor, part, tracker, workingCopyBackupService: workingCopyBackupService, instantiationService };
· ────────
108 │ }
╰────

× Unexpected token
╭─[pass/oxc-3948-1.ts:107:20]
106
107return { accessor, part, tracker, workingCopyBackupService: workingCopyBackupService, instantiationService };
· ─
108 │ }
╰────

× Unexpected token
╭─[fail/oxc-169.js:2:1]
Expand Down
16 changes: 4 additions & 12 deletions tasks/coverage/parser_typescript.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11382,20 +11382,12 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts"
╰────
help: either remove this super, or extend the class

× 'private' modifier cannot be used here.
╭─[conformance/classes/indexMemberDeclarations/privateIndexer2.ts:4:5]
3 │ var x = {
4 │ private [x: string]: string;
· ───────
5 │ }
╰────

× Expected `]` but found `:`
╭─[conformance/classes/indexMemberDeclarations/privateIndexer2.ts:4:15]
× Expected `,` but found `[`
╭─[conformance/classes/indexMemberDeclarations/privateIndexer2.ts:4:13]
3 │ var x = {
4 │ private [x: string]: string;
·
· ╰── `]` expected
· ┬
· ╰── `,` expected
5 │ }
╰────

Expand Down
4 changes: 3 additions & 1 deletion tasks/coverage/prettier_misc.snap
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
prettier_misc Summary:
AST Parsed : 21/21 (100.00%)
Positive Passed: 13/21 (61.90%)
Positive Passed: 11/21 (52.38%)
Expect to Parse: "pass/oxc-1740.tsx"
Expect to Parse: "pass/oxc-2087.ts"
Expect to Parse: "pass/oxc-2394.ts"
Expect to Parse: "pass/oxc-2674.tsx"
Expect to Parse: "pass/oxc-2723.jsx"
Expect to Parse: "pass/oxc-2948-2.ts"
Expect to Parse: "pass/oxc-3910.ts"
Expect to Parse: "pass/oxc-3948-1.ts"
Expect to Parse: "pass/swc-1627.js"
Expect to Parse: "pass/swc-8243.tsx"

0 comments on commit f2ba061

Please sign in to comment.