@@ -5052,7 +5052,7 @@ and parse_type_representation ?current_type_name_path ?inline_types_context p =
50525052 match p.Parser. token with
50535053 | Bar | Uident _ | DocComment _ ->
50545054 Parsetree. Ptype_variant (parse_type_constructor_declarations p)
5055- | At ->
5055+ | At -> (
50565056 (* Attributes can prefix either a variant (constructor list), a record, or an
50575057 open/extensible variant marker (`..`). Peek past attributes and any doc
50585058 comments to decide which kind it is. *)
@@ -5061,39 +5061,47 @@ and parse_type_representation ?current_type_name_path ?inline_types_context p =
50615061 ignore (parse_attributes state);
50625062 let rec skip_docs () =
50635063 match state.Parser. token with
5064- | DocComment _ -> Parser. next state; skip_docs ()
5064+ | DocComment _ ->
5065+ Parser. next state;
5066+ skip_docs ()
50655067 | _ -> ()
50665068 in
50675069 skip_docs () ;
50685070 state.Parser. token)
50695071 in
5070- ( match after_attrs with
5072+ match after_attrs with
50715073 | Lbrace ->
5072- (* consume the attributes and any doc comments before the record *)
5073- ignore (parse_attributes p);
5074- let rec skip_docs () =
5075- match p.Parser. token with
5076- | DocComment _ -> Parser. next p; skip_docs ()
5077- | _ -> ()
5078- in
5079- skip_docs () ;
5080- Parsetree. Ptype_record
5081- (parse_record_declaration ?current_type_name_path ?inline_types_context p)
5074+ (* consume the attributes and any doc comments before the record *)
5075+ ignore (parse_attributes p);
5076+ let rec skip_docs () =
5077+ match p.Parser. token with
5078+ | DocComment _ ->
5079+ Parser. next p;
5080+ skip_docs ()
5081+ | _ -> ()
5082+ in
5083+ skip_docs () ;
5084+ Parsetree. Ptype_record
5085+ (parse_record_declaration ?current_type_name_path
5086+ ?inline_types_context p)
50825087 | DotDot ->
5083- (* attributes before an open variant marker; consume attrs/docs then handle `..` *)
5084- ignore (parse_attributes p);
5085- let rec skip_docs () =
5086- match p.Parser. token with
5087- | DocComment _ -> Parser. next p; skip_docs ()
5088- | _ -> ()
5089- in
5090- skip_docs () ;
5091- Parser. next p; (* consume DotDot *)
5092- Ptype_open
5088+ (* attributes before an open variant marker; consume attrs/docs then handle `..` *)
5089+ ignore (parse_attributes p);
5090+ let rec skip_docs () =
5091+ match p.Parser. token with
5092+ | DocComment _ ->
5093+ Parser. next p;
5094+ skip_docs ()
5095+ | _ -> ()
5096+ in
5097+ skip_docs () ;
5098+ Parser. next p;
5099+ (* consume DotDot *)
5100+ Ptype_open
50935101 | _ ->
5094- (* fall back to variant constructor declarations; leave attributes for the
5102+ (* fall back to variant constructor declarations; leave attributes for the
50955103 constructor parsing so they attach to the first constructor. *)
5096- Parsetree. Ptype_variant (parse_type_constructor_declarations p))
5104+ Parsetree. Ptype_variant (parse_type_constructor_declarations p))
50975105 | Lbrace ->
50985106 Parsetree. Ptype_record
50995107 (parse_record_declaration ?current_type_name_path ?inline_types_context
@@ -5663,30 +5671,37 @@ and parse_type_equation_and_representation ?current_type_name_path
56635671 (* optionally skip a run of doc comments before deciding *)
56645672 let rec skip_docs () =
56655673 match state.Parser. token with
5666- | DocComment _ -> Parser. next state; skip_docs ()
5674+ | DocComment _ ->
5675+ Parser. next state;
5676+ skip_docs ()
56675677 | _ -> ()
56685678 in
56695679 skip_docs () ;
56705680 match state.Parser. token with
5671- | Lbrace ->
5681+ | Lbrace -> (
56725682 (* Disambiguate record declaration vs object type.
56735683 Peek inside the braces; if it looks like an object (String/Dot/DotDot/DotDotDot),
56745684 then this is a manifest type expression, not a representation. If it looks like
56755685 a record field (e.g. Lident or attributes before one), treat as representation. *)
5676- Parser. next state; (* consume Lbrace *)
5686+ Parser. next state;
5687+ (* consume Lbrace *)
56775688 ignore (parse_attributes state);
56785689 skip_docs () ;
5679- (match state.Parser. token with
5680- | String _ | Dot | DotDot | DotDotDot -> false (* object type => manifest *)
5681- | _ -> true ) (* record decl => representation *)
5682- | Bar -> true (* variant constructor list *)
5683- | DotDot -> true (* extensible/open variant ".." *)
5684- | Uident _ -> (* constructor vs module-qualified manifest *)
5690+ match state.Parser. token with
5691+ | String _ | Dot | DotDot | DotDotDot ->
5692+ false (* object type => manifest *)
5693+ | _ -> true
5694+ (* record decl => representation *) )
5695+ | Bar -> true (* variant constructor list *)
5696+ | DotDot -> true (* extensible/open variant ".." *)
5697+ | Uident _ -> (
5698+ (* constructor vs module-qualified manifest *)
56855699 Parser. next state;
5686- (match state.Parser. token with
5687- | Dot -> false (* M.t => manifest *)
5688- | _ -> true ) (* Uident starting a constructor *)
5689- | DocComment _ -> true (* doc before constructor list *)
5700+ match state.Parser. token with
5701+ | Dot -> false (* M.t => manifest *)
5702+ | _ -> true
5703+ (* Uident starting a constructor *) )
5704+ | DocComment _ -> true (* doc before constructor list *)
56905705 | _ -> false )
56915706 in
56925707 if is_representation_after_attrs then
0 commit comments