Skip to content

Commit c28f560

Browse files
authored
Compatibility with OCaml 5.1 (#1150)
* Ensure compatibility with OCaml 5.1
1 parent 66abbbd commit c28f560

File tree

6 files changed

+38
-12
lines changed

6 files changed

+38
-12
lines changed

.github/workflows/build-and-test.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ jobs:
2222
- windows-latest
2323
ocaml-compiler:
2424
- 4.14.x
25+
- 5.0.x
26+
- ocaml-variants.5.1.0+trunk
27+
exclude:
28+
- os: windows-latest
29+
ocaml-compiler: 5.0.x
30+
- os: windows-latest
31+
ocaml-compiler: ocaml-variants.5.1.0+trunk
32+
- os: macos-latest
33+
ocaml-compiler: 5.0.x
34+
- os: macos-latest
35+
ocaml-compiler: ocaml-variants.5.1.0+trunk
2536

2637
runs-on: ${{ matrix.os }}
2738

@@ -60,20 +71,26 @@ jobs:
6071
opam-repository-mingw: https://github.com/ocaml-opam/opam-repository-mingw.git#sunset
6172
default: https://github.com/ocaml/opam-repository.git
6273
63-
- name: Install opam packages
74+
- name: Build and install opam packages
6475
run: opam install .
6576

66-
# the makefile explains why we don't use test dependencies
77+
# the makefile explains why we don't use --with-test
78+
# ppx expect is not yet compatible with 5.1 and test output vary from one
79+
# compiler to another. We only test on 4.14.
6780
- name: Install test dependencies
81+
if: matrix.ocaml-compiler == '4.14.x'
6882
run: opam exec -- make install-test-deps
6983

70-
- name: Run build
84+
- name: Run build @all
85+
if: matrix.ocaml-compiler == '4.14.x'
7186
run: opam exec -- make all
7287

7388
- name: Run the unit tests
89+
if: matrix.ocaml-compiler == '4.14.x'
7490
run: opam exec -- make test-ocaml
7591

7692
- name: Run the template integration tests
93+
if: matrix.ocaml-compiler == '4.14.x'
7794
run: opam exec -- make test-e2e
7895

7996
coverage:

CHANGES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Unreleased
2+
3+
## Fixes
4+
5+
## Features
6+
7+
- Support building with OCaml 5.0 and 5.1 (#1150)
8+
19
# 1.16.0
210

311
## Fixes

dune-project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ possible and does not make any assumptions about IO.
6565
(csexp (>= 1.5))
6666
(ocamlformat-rpc-lib (>= 0.21.0))
6767
(odoc :with-doc)
68-
ocaml
68+
(ocaml (and (>= 4.14) (< 5.2)))
6969
(merlin-lib (and (>= 4.9) (< 5.0)))))
7070

7171
(package

ocaml-lsp-server.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ depends: [
4141
"csexp" {>= "1.5"}
4242
"ocamlformat-rpc-lib" {>= "0.21.0"}
4343
"odoc" {with-doc}
44-
"ocaml"
44+
"ocaml" {>= "4.14" & < "5.2"}
4545
"merlin-lib" {>= "4.9" & < "5.0"}
4646
]
4747
dev-repo: "git+https://github.com/ocaml/ocaml-lsp.git"

ocaml-lsp-server/src/folding_range.ml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@ let fold_over_parsetree (parsetree : Mreader.parsetree) =
6969
let range = Range.of_loc module_expr.pmod_loc in
7070
push range;
7171
Ast_iterator.default_iterator.module_expr self module_expr
72-
| Parsetree.Pmod_ident _
73-
| Parsetree.Pmod_apply (_, _)
74-
| Parsetree.Pmod_constraint (_, _)
75-
| Parsetree.Pmod_unpack _ | Parsetree.Pmod_extension _ ->
72+
| _ ->
73+
(* We rely on the wildcard pattern to improve compatibility with
74+
multiple OCaml's parsetree versions *)
7675
Ast_iterator.default_iterator.module_expr self module_expr
7776
in
7877

ocaml-lsp-server/src/semantic_highlighting.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,8 @@ end = struct
422422
self.attributes self pld_attributes
423423

424424
let value_binding (self : Ast_iterator.iterator)
425-
({ pvb_pat; pvb_expr; pvb_attributes; pvb_loc = _ } as vb :
426-
Parsetree.value_binding) =
425+
({ pvb_pat; pvb_expr; pvb_attributes; _ } as vb : Parsetree.value_binding)
426+
=
427427
match
428428
match (pvb_pat.ppat_desc, pvb_expr.pexp_desc) with
429429
| Parsetree.Ppat_var fn_name, _ -> (
@@ -749,7 +749,9 @@ end = struct
749749
self.module_type self mt);
750750
`Custom_iterator
751751
| Pmod_extension _ -> `Custom_iterator
752-
| Pmod_unpack _ | Pmod_apply (_, _) | Pmod_structure _ ->
752+
| _ ->
753+
(* We rely on the wildcard pattern to improve compatibility with
754+
multiple OCaml's parsetree versions *)
753755
`Default_iterator
754756
with
755757
| `Custom_iterator -> self.attributes self pmod_attributes

0 commit comments

Comments
 (0)