Skip to content

Commit 43a3675

Browse files
authored
Backport AST changes to Ppat_unpack (#2774)
* parser-std: Backport Ppat_unpack Also backport the `map_loc` change in `Ast_mapper`. * parser-ext: Backport Ppat_unpack We already did a similar change in the past, the parsetree doesn't change. * parser-ext: Backport Ast_mapper map_loc changes * Disable rewriting rule for Ppat_unpack It is no longer valid to rewrite: ((module M) : (module S)) into: (module M : S)
1 parent b25c048 commit 43a3675

20 files changed

Lines changed: 251 additions & 150 deletions

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ profile. This started with version 0.26.0.
88

99
### Highlight
1010

11-
- Support OCaml 5.5 syntax (#2772, @Julow)
11+
- Support OCaml 5.5 syntax (#2772, #2774, @Julow)
1212

1313
- \* Update Odoc's parser to 3.0 (#2757, @Julow)
1414
The indentation of code-blocks containing OCaml code is reduced by 2 to avoid

lib/Extended_ast.ml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,6 @@ module Parse = struct
296296
| {ppat_desc= Ppat_record (fields, flag); _} as e ->
297297
let fields = List.map ~f:(pat_record_field m) fields in
298298
{e with ppat_desc= Ppat_record (fields, flag)}
299-
(* [(module M) : (module T)] -> [(module M : T)] *)
300-
| { ppat_desc=
301-
Ppat_constraint
302-
( {ppat_desc= Ppat_unpack (name, None); ppat_attributes= []; _}
303-
, {ptyp_desc= Ptyp_package pt; ptyp_attributes= []; _} )
304-
; _ } as p ->
305-
{p with ppat_desc= Ppat_unpack (name, Some pt)}
306299
| {ppat_desc= Ppat_tuple (l, oc); _} as p ->
307300
let l = List.map ~f:(pat_tuple_elt m) l in
308301
{p with ppat_desc= Ppat_tuple (l, oc)}

test/passing/refs.ahrefs/first_class_module.ml.ref

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,16 @@ let x = (module M : S)
122122
module T = (val (x : (module S)))
123123

124124
let _ = (module Int : T[@foo])
125+
126+
let _ = fun ((module X) : (module M.S with type a = a)) -> X.v
127+
let _ = fun (module X : M.S with type a = a) -> X.v
128+
129+
let _ =
130+
let module MS = struct module type S = sig end end in
131+
(fun _ -> ()) (fun (module M1 : MS.S) ((module M2) : (module MS.S)) ->
132+
(module M1 : MS.S), ((module M2) : (module MS.S)))
133+
134+
let _ =
135+
let module MS = struct module type S = sig end end in
136+
(fun _ -> ()) (fun (module M1 : MS.S) ((module M2) : (module MS.S)) ->
137+
((module M1) : (module MS.S)), ((module M2) : (module MS.S)))

test/passing/refs.ahrefs/source.ml.ref

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4672,13 +4672,13 @@ module B' = B
46724672
class b : B.a =
46734673
object
46744674
method a : 'a. 'a M.s -> 'a =
4675-
fun (type a) (module X : M.S with type a = a) -> X.v
4675+
fun (type a) ((module X) : (module M.S with type a = a)) -> X.v
46764676
end
46774677

46784678
class b' : B.a =
46794679
object
46804680
method a : 'a. 'a M'.s -> 'a =
4681-
fun (type a) (module X : M'.S with type a = a) -> X.v
4681+
fun (type a) ((module X) : (module M'.S with type a = a)) -> X.v
46824682
end
46834683
module type FOO = sig
46844684
type t

test/passing/refs.default/first_class_module.ml.ref

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,15 @@ let x = (module M : S)
115115
module T = (val (x : (module S)))
116116

117117
let _ = (module Int : T[@foo])
118+
let _ = fun ((module X) : (module M.S with type a = a)) -> X.v
119+
let _ = fun (module X : M.S with type a = a) -> X.v
120+
121+
let _ =
122+
let module MS = struct module type S = sig end end in
123+
(fun _ -> ()) (fun (module M1 : MS.S) ((module M2) : (module MS.S)) ->
124+
((module M1 : MS.S), ((module M2) : (module MS.S))))
125+
126+
let _ =
127+
let module MS = struct module type S = sig end end in
128+
(fun _ -> ()) (fun (module M1 : MS.S) ((module M2) : (module MS.S)) ->
129+
(((module M1) : (module MS.S)), ((module M2) : (module MS.S))))

test/passing/refs.default/source.ml.ref

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4585,13 +4585,13 @@ module B' = B
45854585
class b : B.a =
45864586
object
45874587
method a : 'a. 'a M.s -> 'a =
4588-
fun (type a) (module X : M.S with type a = a) -> X.v
4588+
fun (type a) ((module X) : (module M.S with type a = a)) -> X.v
45894589
end
45904590

45914591
class b' : B.a =
45924592
object
45934593
method a : 'a. 'a M'.s -> 'a =
4594-
fun (type a) (module X : M'.S with type a = a) -> X.v
4594+
fun (type a) ((module X) : (module M'.S with type a = a)) -> X.v
45954595
end
45964596

45974597
module type FOO = sig

test/passing/refs.janestreet/first_class_module.ml.ref

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,17 @@ let x = (module M : S)
123123
module T = (val (x : (module S)))
124124

125125
let _ = (module Int : T[@foo])
126+
let _ = fun ((module X) : (module M.S with type a = a)) -> X.v
127+
let _ = fun (module X : M.S with type a = a) -> X.v
128+
129+
let _ =
130+
let module MS = struct module type S = sig end end in
131+
(fun _ -> ()) (fun (module M1 : MS.S) ((module M2) : (module MS.S)) ->
132+
(module M1 : MS.S), ((module M2) : (module MS.S)))
133+
;;
134+
135+
let _ =
136+
let module MS = struct module type S = sig end end in
137+
(fun _ -> ()) (fun (module M1 : MS.S) ((module M2) : (module MS.S)) ->
138+
((module M1) : (module MS.S)), ((module M2) : (module MS.S)))
139+
;;

test/passing/refs.janestreet/source.ml.ref

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5078,12 +5078,14 @@ module B' = B
50785078

50795079
class b : B.a =
50805080
object
5081-
method a : 'a. 'a M.s -> 'a = fun (type a) (module X : M.S with type a = a) -> X.v
5081+
method a : 'a. 'a M.s -> 'a =
5082+
fun (type a) ((module X) : (module M.S with type a = a)) -> X.v
50825083
end
50835084

50845085
class b' : B.a =
50855086
object
5086-
method a : 'a. 'a M'.s -> 'a = fun (type a) (module X : M'.S with type a = a) -> X.v
5087+
method a : 'a. 'a M'.s -> 'a =
5088+
fun (type a) ((module X) : (module M'.S with type a = a)) -> X.v
50875089
end
50885090

50895091
module type FOO = sig

test/passing/refs.ocamlformat/first_class_module.ml.ref

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,17 @@ let x = (module M : S)
118118
module T = (val (x : (module S)))
119119

120120
let _ = (module Int : T[@foo])
121+
122+
let _ = fun ((module X) : (module M.S with type a = a)) -> X.v
123+
124+
let _ = fun (module X : M.S with type a = a) -> X.v
125+
126+
let _ =
127+
let module MS = struct module type S = sig end end in
128+
(fun _ -> ()) (fun (module M1 : MS.S) ((module M2) : (module MS.S)) ->
129+
((module M1 : MS.S), ((module M2) : (module MS.S))) )
130+
131+
let _ =
132+
let module MS = struct module type S = sig end end in
133+
(fun _ -> ()) (fun (module M1 : MS.S) ((module M2) : (module MS.S)) ->
134+
(((module M1) : (module MS.S)), ((module M2) : (module MS.S))) )

test/passing/refs.ocamlformat/source.ml.ref

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5185,13 +5185,13 @@ module B' = B
51855185
class b : B.a =
51865186
object
51875187
method a : 'a. 'a M.s -> 'a =
5188-
fun (type a) (module X : M.S with type a = a) -> X.v
5188+
fun (type a) ((module X) : (module M.S with type a = a)) -> X.v
51895189
end
51905190

51915191
class b' : B.a =
51925192
object
51935193
method a : 'a. 'a M'.s -> 'a =
5194-
fun (type a) (module X : M'.S with type a = a) -> X.v
5194+
fun (type a) ((module X) : (module M'.S with type a = a)) -> X.v
51955195
end
51965196

51975197
module type FOO = sig

0 commit comments

Comments
 (0)