Skip to content

Commit 1f36000

Browse files
committed
Lookahead if we are in variant
1 parent 89afd49 commit 1f36000

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

compiler/syntax/src/res_core.ml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4885,16 +4885,27 @@ and parse_constr_decl_args p =
48854885
* | constr-name const-args
48864886
* | attrs constr-name const-args *)
48874887
and parse_type_constructor_declaration_with_bar p =
4888-
let doc_comment_attrs =
4889-
match p.Parser.token with
4890-
| DocComment (loc, s) ->
4891-
Parser.next p;
4892-
[doc_comment_to_attribute loc s]
4893-
| _ -> []
4888+
let is_constructor_with_bar p =
4889+
Parser.lookahead p (fun state ->
4890+
match state.Parser.token with
4891+
| DocComment _ -> (
4892+
Parser.next state;
4893+
match state.token with
4894+
| Bar -> true
4895+
| _ -> false)
4896+
| Bar -> true
4897+
| _ -> false)
48944898
in
4895-
let has_doc_comment = not (doc_comment_attrs = []) in
48964899
match p.Parser.token with
4897-
| Bar ->
4900+
| _ when is_constructor_with_bar p ->
4901+
let doc_comment_attrs =
4902+
match p.Parser.token with
4903+
| DocComment (loc, s) ->
4904+
Parser.next p;
4905+
[doc_comment_to_attribute loc s]
4906+
| _ -> []
4907+
in
4908+
let has_doc_comment = not (doc_comment_attrs = []) in
48984909
let start_pos = p.Parser.start_pos in
48994910
Parser.next p;
49004911
let constr = parse_type_constructor_declaration ~start_pos p in
@@ -4946,6 +4957,7 @@ and parse_type_constructor_declarations ?first p =
49464957
let first_constr_decl =
49474958
match first with
49484959
| None ->
4960+
(* bar *)
49494961
let doc_comment_attrs =
49504962
match p.Parser.token with
49514963
| DocComment (loc, s) ->

0 commit comments

Comments
 (0)