Skip to content

Commit 56cc5f7

Browse files
committed
Fix issue where an inline record with attributes did not parse.
This did not parse without a `,` after the field: ```res type inlineWithAttrs = | A({@as("VALUE") value: string}) ``` Fixes #6497
1 parent c1b9701 commit 56cc5f7

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
- Allow empty inline records in variants. https://github.com/rescript-lang/rescript-compiler/pull/6494
1818
- Allow empty record patterns in pattern matching. https://github.com/rescript-lang/rescript-compiler/pull/6494
1919

20+
#### :bug: Bug Fix
21+
- Fix issue where an inline record with attributes did not parse. https://github.com/rescript-lang/rescript-compiler/pull/6499
22+
2023
# 11.0.0-rc.6
2124

2225
#### :rocket: New Feature

jscomp/syntax/src/res_core.ml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4675,12 +4675,15 @@ and parseConstrDeclArgs p =
46754675
let attrs =
46764676
if optional then optionalAttr :: attrs else attrs
46774677
in
4678-
Parser.expect Comma p;
46794678
{field with Parsetree.pld_attributes = attrs}
46804679
in
4681-
first
4682-
:: parseCommaDelimitedRegion ~grammar:Grammar.FieldDeclarations
4683-
~closing:Rbrace ~f:parseFieldDeclarationRegion p
4680+
if p.token = Rbrace then [first]
4681+
else (
4682+
Parser.expect Comma p;
4683+
first
4684+
:: parseCommaDelimitedRegion
4685+
~grammar:Grammar.FieldDeclarations ~closing:Rbrace
4686+
~f:parseFieldDeclarationRegion p)
46844687
in
46854688
Parser.expect Rbrace p;
46864689
Parser.optional p Comma |> ignore;

jscomp/syntax/tests/parsing/grammar/expressions/expected/record.res.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,7 @@ type nonrec multipleWithAttrs = {
4242
x: int ;
4343
y: string [@res.optional ][@attr ]}
4444
type nonrec singleWithAttrs = {
45-
y: string [@res.optional ][@attr ]}
45+
y: string [@res.optional ][@attr ]}
46+
type nonrec inlineWithAttrs =
47+
| A of {
48+
value: string [@as {js|VALUE|js}]}

jscomp/syntax/tests/parsing/grammar/expressions/record.res

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,6 @@ type ttt = {x:int, y?: string}
4949

5050
type multipleWithAttrs = {x:int, @attr y?: string}
5151

52-
type singleWithAttrs = {@attr y?: string}
52+
type singleWithAttrs = {@attr y?: string}
53+
54+
type inlineWithAttrs = | A({@as("VALUE") value: string})

0 commit comments

Comments
 (0)