diff --git a/CHANGELOG.md b/CHANGELOG.md index beb8586b46..15601b2b74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,9 @@ - Allow empty inline records in variants. https://github.com/rescript-lang/rescript-compiler/pull/6494 - Allow empty record patterns in pattern matching. https://github.com/rescript-lang/rescript-compiler/pull/6494 +#### :bug: Bug Fix +- Fix issue where an inline record with attributes did not parse. https://github.com/rescript-lang/rescript-compiler/pull/6499 + # 11.0.0-rc.6 #### :rocket: New Feature diff --git a/jscomp/syntax/src/res_core.ml b/jscomp/syntax/src/res_core.ml index b2d2b01230..d27f61a03a 100644 --- a/jscomp/syntax/src/res_core.ml +++ b/jscomp/syntax/src/res_core.ml @@ -4675,12 +4675,15 @@ and parseConstrDeclArgs p = let attrs = if optional then optionalAttr :: attrs else attrs in - Parser.expect Comma p; {field with Parsetree.pld_attributes = attrs} in - first - :: parseCommaDelimitedRegion ~grammar:Grammar.FieldDeclarations - ~closing:Rbrace ~f:parseFieldDeclarationRegion p + if p.token = Rbrace then [first] + else ( + Parser.expect Comma p; + first + :: parseCommaDelimitedRegion + ~grammar:Grammar.FieldDeclarations ~closing:Rbrace + ~f:parseFieldDeclarationRegion p) in Parser.expect Rbrace p; Parser.optional p Comma |> ignore; diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/record.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/record.res.txt index 03791249e9..a15646a13d 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/record.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/record.res.txt @@ -42,4 +42,7 @@ type nonrec multipleWithAttrs = { x: int ; y: string [@res.optional ][@attr ]} type nonrec singleWithAttrs = { - y: string [@res.optional ][@attr ]} \ No newline at end of file + y: string [@res.optional ][@attr ]} +type nonrec inlineWithAttrs = + | A of { + value: string [@as {js|VALUE|js}]} \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/record.res b/jscomp/syntax/tests/parsing/grammar/expressions/record.res index 8a29bfa92c..8a78964ae7 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/record.res +++ b/jscomp/syntax/tests/parsing/grammar/expressions/record.res @@ -49,4 +49,6 @@ type ttt = {x:int, y?: string} type multipleWithAttrs = {x:int, @attr y?: string} -type singleWithAttrs = {@attr y?: string} \ No newline at end of file +type singleWithAttrs = {@attr y?: string} + +type inlineWithAttrs = | A({@as("VALUE") value: string}) \ No newline at end of file