This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 656
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rome_js_parser): Crash at empty default export #4670
- Loading branch information
1 parent
2716986
commit f8050a5
Showing
3 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
crates/rome_js_parser/test_data/inline/err/export_default_expression_broken.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default ; | ||
export default @decorator | ||
export default | ||
export default @decorator |
203 changes: 203 additions & 0 deletions
203
crates/rome_js_parser/test_data/inline/err/export_default_expression_broken.rast
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
JsModule { | ||
interpreter_token: missing (optional), | ||
directives: JsDirectiveList [], | ||
items: JsModuleItemList [ | ||
JsBogusStatement { | ||
items: [ | ||
JsDecoratorList [], | ||
EXPORT_KW@0..7 "export" [] [Whitespace(" ")], | ||
DEFAULT_KW@7..15 "default" [] [Whitespace(" ")], | ||
], | ||
}, | ||
JsEmptyStatement { | ||
semicolon_token: SEMICOLON@15..16 ";" [] [], | ||
}, | ||
JsBogusStatement { | ||
items: [ | ||
JsDecoratorList [], | ||
EXPORT_KW@16..24 "export" [Newline("\n")] [Whitespace(" ")], | ||
DEFAULT_KW@24..32 "default" [] [Whitespace(" ")], | ||
JsBogusStatement { | ||
items: [ | ||
JsDecorator { | ||
at_token: AT@32..33 "@" [] [], | ||
expression: JsIdentifierExpression { | ||
name: JsReferenceIdentifier { | ||
value_token: IDENT@33..42 "decorator" [] [], | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
JsBogusStatement { | ||
items: [ | ||
JsDecoratorList [], | ||
EXPORT_KW@42..50 "export" [Newline("\n")] [Whitespace(" ")], | ||
DEFAULT_KW@50..57 "default" [] [], | ||
], | ||
}, | ||
JsBogusStatement { | ||
items: [ | ||
JsDecoratorList [], | ||
EXPORT_KW@57..65 "export" [Newline("\n")] [Whitespace(" ")], | ||
DEFAULT_KW@65..73 "default" [] [Whitespace(" ")], | ||
JsBogusStatement { | ||
items: [ | ||
JsDecorator { | ||
at_token: AT@73..74 "@" [] [], | ||
expression: JsIdentifierExpression { | ||
name: JsReferenceIdentifier { | ||
value_token: IDENT@74..83 "decorator" [] [], | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
eof_token: EOF@83..84 "" [Newline("\n")] [], | ||
} | ||
|
||
0: JS_MODULE@0..84 | ||
0: (empty) | ||
1: JS_DIRECTIVE_LIST@0..0 | ||
2: JS_MODULE_ITEM_LIST@0..83 | ||
0: JS_BOGUS_STATEMENT@0..15 | ||
0: JS_DECORATOR_LIST@0..0 | ||
1: EXPORT_KW@0..7 "export" [] [Whitespace(" ")] | ||
2: DEFAULT_KW@7..15 "default" [] [Whitespace(" ")] | ||
1: JS_EMPTY_STATEMENT@15..16 | ||
0: SEMICOLON@15..16 ";" [] [] | ||
2: JS_BOGUS_STATEMENT@16..42 | ||
0: JS_DECORATOR_LIST@16..16 | ||
1: EXPORT_KW@16..24 "export" [Newline("\n")] [Whitespace(" ")] | ||
2: DEFAULT_KW@24..32 "default" [] [Whitespace(" ")] | ||
3: JS_BOGUS_STATEMENT@32..42 | ||
0: JS_DECORATOR@32..42 | ||
0: AT@32..33 "@" [] [] | ||
1: JS_IDENTIFIER_EXPRESSION@33..42 | ||
0: JS_REFERENCE_IDENTIFIER@33..42 | ||
0: IDENT@33..42 "decorator" [] [] | ||
3: JS_BOGUS_STATEMENT@42..57 | ||
0: JS_DECORATOR_LIST@42..42 | ||
1: EXPORT_KW@42..50 "export" [Newline("\n")] [Whitespace(" ")] | ||
2: DEFAULT_KW@50..57 "default" [] [] | ||
4: JS_BOGUS_STATEMENT@57..83 | ||
0: JS_DECORATOR_LIST@57..57 | ||
1: EXPORT_KW@57..65 "export" [Newline("\n")] [Whitespace(" ")] | ||
2: DEFAULT_KW@65..73 "default" [] [Whitespace(" ")] | ||
3: JS_BOGUS_STATEMENT@73..83 | ||
0: JS_DECORATOR@73..83 | ||
0: AT@73..74 "@" [] [] | ||
1: JS_IDENTIFIER_EXPRESSION@74..83 | ||
0: JS_REFERENCE_IDENTIFIER@74..83 | ||
0: IDENT@74..83 "decorator" [] [] | ||
3: EOF@83..84 "" [Newline("\n")] [] | ||
-- | ||
export_default_expression_broken.js:1:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
||
× expected a class, a function, or a variable declaration but instead found ';' | ||
|
||
> 1 │ export default ; | ||
│ ^ | ||
2 │ export default @decorator | ||
3 │ export default | ||
|
||
i Expected a class, a function, or a variable declaration here | ||
|
||
> 1 │ export default ; | ||
│ ^ | ||
2 │ export default @decorator | ||
3 │ export default | ||
|
||
-- | ||
export_default_expression_broken.js:2:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
||
× Decorators are not valid here. | ||
|
||
1 │ export default ; | ||
> 2 │ export default @decorator | ||
│ ^^^^^^^^^^ | ||
3 │ export default | ||
4 │ export default @decorator | ||
|
||
i Decorators are only valid on class declarations, class expressions, and class methods. | ||
|
||
-- | ||
export_default_expression_broken.js:3:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
||
× expected a class, a function, or a variable declaration but instead found 'export' | ||
|
||
1 │ export default ; | ||
2 │ export default @decorator | ||
> 3 │ export default | ||
│ ^^^^^^ | ||
4 │ export default @decorator | ||
5 │ | ||
|
||
i Expected a class, a function, or a variable declaration here | ||
|
||
1 │ export default ; | ||
2 │ export default @decorator | ||
> 3 │ export default | ||
│ ^^^^^^ | ||
4 │ export default @decorator | ||
5 │ | ||
|
||
-- | ||
export_default_expression_broken.js:4:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
||
× expected a class, a function, or a variable declaration but instead found 'export' | ||
|
||
2 │ export default @decorator | ||
3 │ export default | ||
> 4 │ export default @decorator | ||
│ ^^^^^^ | ||
5 │ | ||
|
||
i Expected a class, a function, or a variable declaration here | ||
|
||
2 │ export default @decorator | ||
3 │ export default | ||
> 4 │ export default @decorator | ||
│ ^^^^^^ | ||
5 │ | ||
|
||
-- | ||
export_default_expression_broken.js:4:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
||
× Decorators are not valid here. | ||
|
||
2 │ export default @decorator | ||
3 │ export default | ||
> 4 │ export default @decorator | ||
│ ^^^^^^^^^^ | ||
5 │ | ||
|
||
i Decorators are only valid on class declarations, class expressions, and class methods. | ||
|
||
-- | ||
export_default_expression_broken.js:5:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
||
× expected a class, a function, or a variable declaration but instead found the end of the file | ||
|
||
3 │ export default | ||
4 │ export default @decorator | ||
> 5 │ | ||
│ | ||
|
||
i Expected a class, a function, or a variable declaration here | ||
|
||
3 │ export default | ||
4 │ export default @decorator | ||
> 5 │ | ||
│ | ||
|
||
-- | ||
export default ; | ||
export default @decorator | ||
export default | ||
export default @decorator |