Skip to content

Commit 01ec999

Browse files
authored
5.5 support: Backport Ptype_external (#2775)
The original string syntax (eg. `{del| .. |del}`) is not respected because this is probably unecessary.
1 parent 43a3675 commit 01ec999

41 files changed

Lines changed: 427 additions & 3 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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, #2774, @Julow)
11+
- Support OCaml 5.5 syntax (#2772, #2774, #2775, @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/Ast.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ end
336336
module Tyd = struct
337337
let is_simple x =
338338
match x.ptype_kind with
339-
| Ptype_abstract | Ptype_open -> true
339+
| Ptype_abstract | Ptype_open | Ptype_external _ -> true
340340
| Ptype_variant _ | Ptype_record _ -> false
341341
end
342342

lib/Exposed.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ module Right = struct
6363
| {ptype_cstrs= _ :: _ as cstrs; _} ->
6464
(* type a = ... constraint left = < ... > *)
6565
list ~elt:(fun (_left, right, _loc) -> core_type right) cstrs
66-
| {ptype_kind= Ptype_open | Ptype_record _; _} -> false
66+
| {ptype_kind= Ptype_open | Ptype_record _ | Ptype_external _; _} ->
67+
false
6768
| {ptype_kind= Ptype_abstract; ptype_manifest= None; _} -> false
6869
| {ptype_kind= Ptype_abstract; ptype_manifest= Some manifest; _} ->
6970
(* type a = < ... > *)

lib/Fmt_ast.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3602,6 +3602,11 @@ and fmt_type_declaration c ?(kw = "") ?(nonrec_kw = "") ?name ?(eq = "=")
36023602
$ p.box_record (list_fl lbl_decls fmt_decl)
36033603
$ p.break_after $ p.docked_after
36043604
| Ptype_open -> box_manifest (fmt_manifest m $ str " ..")
3605+
| Ptype_external n ->
3606+
box_manifest
3607+
( fmt_manifest m $ space_break $ str "external \""
3608+
$ str (String.escaped n)
3609+
$ str "\"" )
36053610
in
36063611
let fmt_cstr (t1, t2, loc) =
36073612
Cmts.fmt c loc

test/passing/refs.ahrefs/types-compact-space_around-docked.ml.ref

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,16 @@ type t =
235235
exp2 : Exp.t;
236236
loc : Location.t;
237237
} (** *exp1 <- exp2 with exp2:typ *)
238+
239+
type t = external "t"
240+
type u = external "u"
241+
242+
module M : sig
243+
type t = external "foo"
244+
end = struct
245+
type t = external "foo"
246+
end
247+
248+
type t = external ""
249+
type t = external "\003"
250+
type t = external "\\\\\\"

test/passing/refs.ahrefs/types-compact-space_around.ml.ref

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,16 @@ type t =
235235
exp2 : Exp.t;
236236
loc : Location.t;
237237
} (** *exp1 <- exp2 with exp2:typ *)
238+
239+
type t = external "t"
240+
type u = external "u"
241+
242+
module M : sig
243+
type t = external "foo"
244+
end = struct
245+
type t = external "foo"
246+
end
247+
248+
type t = external ""
249+
type t = external "\003"
250+
type t = external "\\\\\\"

test/passing/refs.ahrefs/types-compact.ml.ref

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,16 @@ type t =
235235
exp2 : Exp.t;
236236
loc : Location.t;
237237
} (** *exp1 <- exp2 with exp2:typ *)
238+
239+
type t = external "t"
240+
type u = external "u"
241+
242+
module M : sig
243+
type t = external "foo"
244+
end = struct
245+
type t = external "foo"
246+
end
247+
248+
type t = external ""
249+
type t = external "\003"
250+
type t = external "\\\\\\"

test/passing/refs.ahrefs/types-indent.ml.ref

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,16 @@ type t =
275275
exp2 : Exp.t;
276276
loc : Location.t;
277277
} (** *exp1 <- exp2 with exp2:typ *)
278+
279+
type t = external "t"
280+
type u = external "u"
281+
282+
module M : sig
283+
type t = external "foo"
284+
end = struct
285+
type t = external "foo"
286+
end
287+
288+
type t = external ""
289+
type t = external "\003"
290+
type t = external "\\\\\\"

test/passing/refs.ahrefs/types-sparse-space_around.ml.ref

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,16 @@ type t =
275275
exp2 : Exp.t;
276276
loc : Location.t;
277277
} (** *exp1 <- exp2 with exp2:typ *)
278+
279+
type t = external "t"
280+
type u = external "u"
281+
282+
module M : sig
283+
type t = external "foo"
284+
end = struct
285+
type t = external "foo"
286+
end
287+
288+
type t = external ""
289+
type t = external "\003"
290+
type t = external "\\\\\\"

test/passing/refs.ahrefs/types-sparse.ml.ref

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,16 @@ type t =
275275
exp2 : Exp.t;
276276
loc : Location.t;
277277
} (** *exp1 <- exp2 with exp2:typ *)
278+
279+
type t = external "t"
280+
type u = external "u"
281+
282+
module M : sig
283+
type t = external "foo"
284+
end = struct
285+
type t = external "foo"
286+
end
287+
288+
type t = external ""
289+
type t = external "\003"
290+
type t = external "\\\\\\"

0 commit comments

Comments
 (0)