Skip to content

Commit d945711

Browse files
committed
Add error messages for dangling doc comments/attributes and mutable in record type definition.
Fixes #6111
1 parent 29e27e4 commit d945711

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
- Make "rescript format" work with node 10 again and set minimum required node version to 10 in package.json. https://github.com/rescript-lang/rescript-compiler/pull/6186
3030
- Fix partial application for uncurried functions with labeled args https://github.com/rescript-lang/rescript-compiler/pull/6198
31+
- Add error messages for dangling doc comments/attributes and mutable in record type definition. https://github.com/rescript-lang/rescript-compiler/pull/6206
3132

3233
# 11.0.0-alpha.4
3334

res_syntax/src/res_core.ml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4498,7 +4498,18 @@ and parseFieldDeclarationRegion ?foundObjectField p =
44984498
let loc = mkLoc startPos typ.ptyp_loc.loc_end in
44994499
let attrs = if optional then optionalAttr :: attrs else attrs in
45004500
Some (Ast_helper.Type.field ~attrs ~loc ~mut name typ)
4501-
| _ -> None
4501+
| _ ->
4502+
if attrs <> [] then
4503+
Parser.err ~startPos p
4504+
(Diagnostics.message
4505+
"Attributes and doc comments can only be used at the beginning of a \
4506+
field declaration");
4507+
if mut = Mutable then
4508+
Parser.err ~startPos p
4509+
(Diagnostics.message
4510+
"The `mutable` qualifier can only be used at the beginning of a \
4511+
field declaration");
4512+
None
45024513

45034514
(* record-decl ::=
45044515
* | { field-decl }

0 commit comments

Comments
 (0)