Skip to content

Fix parse error on doc comment before "and" in type def #7001

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

Merged
merged 2 commits into from
Sep 2, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- Fix incorrect printing of external with `@as` attribute and `_` placholder (fixed argument). https://github.com/rescript-lang/rescript-compiler/pull/6970
- Disallow spreading anything but regular variants inside of other variants. https://github.com/rescript-lang/rescript-compiler/pull/6980
- Fix comment removed when function signature has `type` keyword. https://github.com/rescript-lang/rescript-compiler/pull/6997
- Fix parse error on doc comment before "and" in type def. https://github.com/rescript-lang/rescript-compiler/pull/7001

#### :house: Internal

Expand Down
2 changes: 1 addition & 1 deletion jscomp/syntax/src/res_core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2511,7 +2511,7 @@ and parse_attributes_and_binding (p : Parser.t) =
let comments = p.comments in

match p.Parser.token with
| At -> (
| At | DocComment (_, _) -> (
let attrs = parse_attributes p in
match p.Parser.token with
| And -> attrs
Expand Down
6 changes: 5 additions & 1 deletion jscomp/syntax/tests/parsing/other/docComments.res
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ let q = 11
* is a multi-line
multiline doc comment
*/
type h = int
type h = int

type pathItem = {}
/** Issue 6844: doc comment before "and" */
and operation = {}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ let z = 34[@@res.doc " This is a doc \226\156\133 comment "]
[@@@res.doc {js|And this is a res.doc module annotation|js}]
let q = 11[@@res.doc {js|And this is a res.doc ✅ annotation|js}]
type nonrec h = int[@@res.doc
" This\n * is a multi-line\n multiline doc comment\n "]
" This\n * is a multi-line\n multiline doc comment\n "]
type nonrec pathItem = {
}
and operation = {
}[@@res.doc " Issue 6844: doc comment before \"and\" "]
6 changes: 5 additions & 1 deletion jscomp/syntax/tests/printer/comments/docComments.res
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ type h = int
@foo @bar @baz let x = 10

/** doc comment and 0 attributes */
let x = 10
let x = 10

type pathItem = {}
/** Issue 6844: doc comment before "and" */
and operation = {}
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ let x = 10

/** doc comment and 0 attributes */
let x = 10

type pathItem = {}
/** Issue 6844: doc comment before "and" */ and operation = {}