Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(parser): allow line breaks between const and enum #8193

Merged
merged 2 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/oxc_parser/src/modifiers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ impl<'a> ParserImpl<'a> {
}

match self.cur_kind() {
Kind::Const => !self.peek_token().is_on_new_line && self.peek_kind() == Kind::Enum,
Kind::Const => self.peek_kind() == Kind::Enum,
Kind::Export => {
self.bump_any();
match self.cur_kind() {
Expand Down
2 changes: 2 additions & 0 deletions tasks/coverage/misc/pass/oxc-8193.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const
enum A {}
4 changes: 2 additions & 2 deletions tasks/coverage/snapshots/codegen_misc.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
codegen_misc Summary:
AST Parsed : 30/30 (100.00%)
Positive Passed: 30/30 (100.00%)
AST Parsed : 31/31 (100.00%)
Positive Passed: 31/31 (100.00%)
4 changes: 2 additions & 2 deletions tasks/coverage/snapshots/parser_misc.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
parser_misc Summary:
AST Parsed : 30/30 (100.00%)
Positive Passed: 30/30 (100.00%)
AST Parsed : 31/31 (100.00%)
Positive Passed: 31/31 (100.00%)
Negative Passed: 26/26 (100.00%)

× Unexpected token
Expand Down
12 changes: 10 additions & 2 deletions tasks/coverage/snapshots/semantic_misc.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
semantic_misc Summary:
AST Parsed : 30/30 (100.00%)
Positive Passed: 19/30 (63.33%)
AST Parsed : 31/31 (100.00%)
Positive Passed: 19/31 (61.29%)
tasks/coverage/misc/pass/oxc-1288.ts
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["from"]
Expand Down Expand Up @@ -170,3 +170,11 @@ semantic error: Scope children mismatch:
after transform: ScopeId(0): [ScopeId(1), ScopeId(2), ScopeId(3)]
rebuilt : ScopeId(0): [ScopeId(1), ScopeId(2)]

tasks/coverage/misc/pass/oxc-8193.ts
semantic error: Scope flags mismatch:
after transform: ScopeId(1): ScopeFlags(StrictMode)
rebuilt : ScopeId(1): ScopeFlags(StrictMode | Function)
Symbol flags mismatch for "A":
after transform: SymbolId(0): SymbolFlags(ConstEnum)
rebuilt : SymbolId(0): SymbolFlags(FunctionScopedVariable)

4 changes: 2 additions & 2 deletions tasks/coverage/snapshots/transformer_misc.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
transformer_misc Summary:
AST Parsed : 30/30 (100.00%)
Positive Passed: 30/30 (100.00%)
AST Parsed : 31/31 (100.00%)
Positive Passed: 31/31 (100.00%)
Loading