Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCaml 5.3 support #2800

Merged
merged 38 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0bf2b3b
OCaml 5.3 support
anmonteiro Sep 3, 2024
d42a171
allow 5.4 in opam file
anmonteiro Oct 19, 2024
d481615
remove with-test flag for now?
anmonteiro Oct 19, 2024
2e1d6d1
add merlin-extend lower bounds
anmonteiro Oct 28, 2024
e22867c
add opam pin
anmonteiro Nov 2, 2024
34819be
move to rtop
anmonteiro Nov 2, 2024
1dca529
?
anmonteiro Nov 2, 2024
238e944
??
anmonteiro Nov 2, 2024
fa0575c
don't use int.max
anmonteiro Nov 2, 2024
148a11a
try something
anmonteiro Nov 2, 2024
a473b37
test on 5.3
anmonteiro Nov 2, 2024
3c8e8a5
hmm
anmonteiro Nov 2, 2024
bc8fb4b
wip
anmonteiro Nov 2, 2024
9e44960
fix
anmonteiro Nov 2, 2024
3ccbb29
wip
anmonteiro Nov 2, 2024
fed5725
don't pin
anmonteiro Nov 2, 2024
77797cf
lol
anmonteiro Nov 2, 2024
9ab2e90
pin in ci step
anmonteiro Nov 3, 2024
d731bd7
no either for < 4.12
anmonteiro Nov 3, 2024
9aeff3a
stag for 4.08+
anmonteiro Nov 3, 2024
b34a686
wip
anmonteiro Nov 3, 2024
eec8130
fix rtop tests
anmonteiro Nov 3, 2024
e526ee1
more conditional
anmonteiro Nov 3, 2024
37a811d
pp_print_break
anmonteiro Nov 3, 2024
0df6bf5
oops
anmonteiro Nov 3, 2024
a605de1
bool
anmonteiro Nov 3, 2024
4874230
fun.id
anmonteiro Nov 3, 2024
555544f
seq
anmonteiro Nov 3, 2024
9f4b050
seq
anmonteiro Nov 3, 2024
e18b95e
more stag stuff
anmonteiro Nov 3, 2024
4bc5fe7
disable some fns?
anmonteiro Nov 3, 2024
284ee83
more
anmonteiro Nov 3, 2024
dcf743d
wip
anmonteiro Nov 3, 2024
13871dc
invert
anmonteiro Nov 3, 2024
85d9df0
fix
anmonteiro Nov 3, 2024
e9586df
oops
anmonteiro Nov 3, 2024
4ea0baa
open stdlib0
anmonteiro Nov 3, 2024
cc63c41
runtest
anmonteiro Nov 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/nix-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- 5_0
- 5_1
- 5_2
- 5_3

runs-on: ubuntu-latest
steps:
Expand All @@ -44,6 +45,7 @@ jobs:
- {ocaml-version: '5_2', os: macos-13}
- {ocaml-version: '4_14', os: macos-14}
- {ocaml-version: '5_2', os: macos-14}
- {ocaml-version: '5_3', os: macos-14}
runs-on: ${{ matrix.setup.os }}
steps:
- uses: actions/checkout@v4
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/opam-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ jobs:
- {ocaml-compiler: '4.10.x', os: ubuntu-latest}
- {ocaml-compiler: '4.12.x', os: ubuntu-latest}
- {ocaml-compiler: '4.14.x', os: ubuntu-latest}
- {ocaml-compiler: 'ocaml-base-compiler.5.3.0~alpha1', os: ubuntu-latest}
- {ocaml-compiler: '4.06.x', os: macos-13}
- {ocaml-compiler: '4.10.x', os: macos-13}
- {ocaml-compiler: '4.12.x', os: macos-13}
- {ocaml-compiler: '4.14.x', os: macos-13}
- {ocaml-compiler: 'ocaml-base-compiler.5.3.0~alpha1', os: macos-13}
# looks like setup-ocaml@v3 can only run actions on windows for
# OCaml >= 4.13
# https://github.com/ocaml/setup-ocaml/issues/822#issuecomment-2215525942
Expand Down Expand Up @@ -58,6 +60,10 @@ jobs:
path: _opam
key: opam-${{ matrix.setup.os }}-${{ matrix.setup.ocaml-compiler }}-${{ hashFiles('**.opam') }}

- name: Pin utop for OCaml 5.3
if: ${{ matrix.setup.ocaml-compiler == 'ocaml-base-compiler.5.3.0~alpha1' }}
run: opam pin add utop --dev-repo

- name: Install dependencies
run: opam install . --deps-only

Expand Down
6 changes: 3 additions & 3 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
(ocaml
(and
(>= "4.06")
(< "5.3")))
(< "5.4")))
(ocamlfind :build)
(dune-build-info
(>= 2.9.3))
(menhir
(>= "20180523"))
(merlin-extend
(>= "0.6"))
(>= "0.6.2"))
fix
ppx_derivers
cppo
Expand All @@ -57,7 +57,7 @@
(ocaml
(and
(>= "4.06")
(< "5.3")))
(< "5.4")))
(reason
(= :version))
(utop
Expand Down
20 changes: 10 additions & 10 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages."${system}".extend (self: super: {
ocamlPackages = super.ocaml-ng.ocamlPackages_5_2;
ocamlPackages = super.ocaml-ng.ocamlPackages_5_3;
});
packages = pkgs.callPackage ./nix { nix-filter = nix-filter.lib; };
in
Expand Down
7 changes: 6 additions & 1 deletion nix/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@

mkShell {
inputsFrom = [ reason ];
nativeBuildInputs = with ocamlPackages; [ utop merlin odoc ocamlformat ];
nativeBuildInputs = with ocamlPackages; [
utop
merlin
odoc
ocamlformat
];
buildInputs =
with ocamlPackages; (if release-mode then [ cacert curl dune-release git ] else [ ]);
}
4 changes: 2 additions & 2 deletions reason.opam
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ homepage: "https://reasonml.github.io/"
bug-reports: "https://github.com/reasonml/reason/issues"
depends: [
"dune" {>= "2.9"}
"ocaml" {>= "4.06" & < "5.3"}
"ocaml" {>= "4.06" & < "5.4"}
"ocamlfind" {build}
"dune-build-info" {>= "2.9.3"}
"menhir" {>= "20180523"}
"merlin-extend" {>= "0.6"}
"merlin-extend" {>= "0.6.2"}
"fix"
"ppx_derivers"
"cppo"
Expand Down
2 changes: 1 addition & 1 deletion rtop.opam
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ homepage: "https://reasonml.github.io/"
bug-reports: "https://github.com/reasonml/reason/issues"
depends: [
"dune" {>= "2.9"}
"ocaml" {>= "4.06" & < "5.3"}
"ocaml" {>= "4.06" & < "5.4"}
"reason" {= version}
"utop" {>= "2.0"}
"cppo"
Expand Down
6 changes: 6 additions & 0 deletions rtop/dune
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
(action
(run cppo -V OCAML:%{ocaml_version} %{deps} -o %{targets})))

(rule
(targets reason_utop.ml)
(deps reason_utop.cppo.ml)
(action
(run cppo -V OCAML:%{ocaml_version} %{deps} -o %{targets})))

(executable
(name rtop)
(public_name rtop)
Expand Down
3 changes: 3 additions & 0 deletions rtop/reason_toploop.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ let main () =
List.exists ((=) "camlp4r") !Topfind.predicates then
print_endline "Reason is incompatible with camlp4!"
else begin
#if OCAML_VERSION >= (5,3,0)
if not (Toploop.prepare Format.err_formatter ()) then raise (Compenv.Exit_with_status 2);
#endif
Toploop.parse_toplevel_phrase := (fun t ->
if !Reason_utop.current_top = UTop then
default_parse_toplevel_phrase t
Expand Down
28 changes: 20 additions & 8 deletions rtop/reason_utop.ml → rtop/reason_utop.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,31 @@ let init_reason () =

(* Printing in Reason syntax *)
let open Reason_toolchain.From_current in
let wrap f g fmt x = g fmt (f x) in
let wrap f g fmt x =
g fmt (f x)
in
#if OCAML_VERSION >= (5,3,0)
let wrap_doc f g fmt x =
let doc_f =
Format_doc.deprecated_printer (fun fmt -> Format.fprintf fmt "%a" g (f x))
in
doc_f fmt
#else
let wrap_doc = wrap
#endif
in
Toploop.print_out_value := wrap copy_out_value Reason_oprint.print_out_value;
Toploop.print_out_type := wrap copy_out_type Reason_oprint.print_out_type;
Toploop.print_out_type := wrap_doc copy_out_type Reason_oprint.print_out_type;
Toploop.print_out_class_type :=
wrap copy_out_class_type Reason_oprint.print_out_class_type;
wrap_doc copy_out_class_type Reason_oprint.print_out_class_type;
Toploop.print_out_module_type :=
wrap copy_out_module_type Reason_oprint.print_out_module_type;
wrap_doc copy_out_module_type Reason_oprint.print_out_module_type;
Toploop.print_out_type_extension :=
wrap copy_out_type_extension Reason_oprint.print_out_type_extension;
wrap_doc copy_out_type_extension Reason_oprint.print_out_type_extension;
Toploop.print_out_sig_item :=
wrap copy_out_sig_item Reason_oprint.print_out_sig_item;
wrap_doc copy_out_sig_item Reason_oprint.print_out_sig_item;
Toploop.print_out_signature :=
wrap (List.map copy_out_sig_item) Reason_oprint.print_out_signature;
wrap_doc (List.map copy_out_sig_item) Reason_oprint.print_out_signature;
Toploop.print_out_phrase :=
wrap copy_out_phrase Reason_oprint.print_out_phrase;
let current_show_fn =
Expand Down Expand Up @@ -122,7 +134,7 @@ let init_ocaml () =
let toggle_syntax () =
match !current_top with RTop -> init_ocaml () | UTop -> init_reason ()

let _ =
let () =
Hashtbl.add
(Toploop.directive_table [@ocaml.warning "-3"])
"toggle_syntax"
Expand Down
12 changes: 11 additions & 1 deletion src/reason-parser/ocaml_util.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ let print_loc ppf loc =


let print_error loc f ppf x =
#if OCAML_VERSION >= (4,8,0)
#if OCAML_VERSION >= (5,3,0)
let error =
let f (fmt: Format_doc.formatter) err =
let doc_f =
Format_doc.deprecated_printer (fun fmt -> Format.fprintf fmt "%a" f err)
in
doc_f fmt
in
Location.error_of_printer ~loc f x in
Location.print_report ppf error
#elif OCAML_VERSION >= (4,8,0)
let error = Location.error_of_printer ~loc f x in
Location.print_report ppf error
#else
Expand Down
Loading