Skip to content

Commit 3e67836

Browse files
committed
fix(syntax): allow private in with constraints
1 parent 2a0f3ba commit 3e67836

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

jscomp/syntax/src/res_core.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6269,12 +6269,16 @@ and parse_with_constraint p =
62696269
(Location.mkloc (Longident.last type_constr.txt) type_constr.loc) )
62706270
| Equal ->
62716271
Parser.next p;
6272+
let private_flag =
6273+
if Parser.optional p Token.Private then Asttypes.Private
6274+
else Asttypes.Public
6275+
in
62726276
let typ_expr = parse_typ_expr p in
62736277
let type_constraints = parse_type_constraints p in
62746278
Parsetree.Pwith_type
62756279
( type_constr,
6276-
Ast_helper.Type.mk ~loc:type_constr.loc ~params ~manifest:typ_expr
6277-
~cstrs:type_constraints
6280+
Ast_helper.Type.mk ~loc:type_constr.loc ~priv:private_flag ~params
6281+
~manifest:typ_expr ~cstrs:type_constraints
62786282
(Location.mkloc (Longident.last type_constr.txt) type_constr.loc) )
62796283
| token ->
62806284
(* TODO: revisit *)

jscomp/syntax/tests/parsing/grammar/modtype/expected/with.res.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module type A =
99
(Foo with type t = 'st constraint 'st = int constraint 'x = int and type
1010
t = 'st constraint 'st = int constraint 'x = int and type t =
1111
'st constraint 'st = int constraint 'x = int)
12+
module type A = (Foo with type t = private string)
1213
module type A = (Foo with type t := string)
1314
module type A = (Foo with type 'a t := string)
1415
module type A = (Foo with type ('a,'b) t := string)

jscomp/syntax/tests/parsing/grammar/modtype/with.res

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module type A = Foo
88
with type t = 'st constraint 'st = int constraint 'x = int
99
and type t = 'st constraint 'st = int constraint 'x = int
1010
and type t = 'st constraint 'st = int constraint 'x = int
11+
module type A = Foo with type t = private string
1112

1213
module type A = Foo with type t := string
1314
module type A = Foo with type t<'a> := string

0 commit comments

Comments
 (0)