Skip to content

Commit 7b375c0

Browse files
authored
Ocaml 5.3 (#7294)
* OCaml 5.3 + some dependency upgrades * "effect" is a reserved word now * no 4.13 * ocamlformat 0.27.0 * Use OCaml 5.3.0 * Run reanalyze on OCaml 5.2.1
1 parent 0f84ac1 commit 7b375c0

Some content is hidden

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

67 files changed

+374
-316
lines changed

.devcontainer/postCreate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Install dev dependencies from OPAM
44
opam init -y --bare --disable-sandboxing
5-
opam switch create 5.2.1 --packages ocaml-option-static
5+
opam switch create 5.3.0 --packages ocaml-option-static
66
opam install . --deps-only -y
77

88
# For IDE support, install the OCaml language server

.github/workflows/ci.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,32 +87,34 @@ jobs:
8787
matrix:
8888
include:
8989
- os: ubuntu-24.04 # x64
90-
ocaml_compiler: ocaml-variants.5.2.1+options,ocaml-option-static
90+
ocaml_compiler: ocaml-variants.5.3.0+options,ocaml-option-static
9191
upload_binaries: true
9292
upload_libs: true
9393
- os: ubuntu-24.04-arm # ARM
94-
ocaml_compiler: ocaml-variants.5.2.1+options,ocaml-option-static
94+
ocaml_compiler: ocaml-variants.5.3.0+options,ocaml-option-static
9595
upload_binaries: true
9696
# Build the playground compiler and run the benchmarks on the fastest runner
9797
build_playground: true
9898
benchmarks: true
9999
- os: macos-13 # x64
100-
ocaml_compiler: 5.2.1
100+
ocaml_compiler: 5.3.0
101101
upload_binaries: true
102102
- os: macos-14 # ARM
103-
ocaml_compiler: 5.2.1
103+
ocaml_compiler: 5.3.0
104104
upload_binaries: true
105105
- os: windows-latest
106-
ocaml_compiler: 5.2.1
106+
ocaml_compiler: 5.3.0
107107
upload_binaries: true
108108

109109
# Verify that the compiler still builds with older OCaml versions
110+
- os: ubuntu-24.04
111+
ocaml_compiler: ocaml-variants.5.2.1+options,ocaml-option-static
112+
# Reanalyze does not work on OCaml 5.3.0 anymore, therefore run it on 5.2.1
113+
run_reanalyze: true
110114
- os: ubuntu-24.04
111115
ocaml_compiler: ocaml-variants.5.0.0+options,ocaml-option-static
112116
- os: ubuntu-24.04
113117
ocaml_compiler: ocaml-variants.4.14.2+options,ocaml-option-static
114-
- os: ubuntu-24.04
115-
ocaml_compiler: ocaml-variants.4.13.0+options,ocaml-option-static
116118

117119
runs-on: ${{matrix.os}}
118120

@@ -299,6 +301,12 @@ jobs:
299301
if: ${{ runner.os == 'Windows' }}
300302
run: opam exec -- make test-syntax
301303

304+
- name: "Syntax: Run reanalyze"
305+
if: matrix.run_reanalyze
306+
run: |
307+
opam install reanalyze
308+
opam exec -- make reanalyze
309+
302310
- name: Build runtime/stdlib
303311
run: ./scripts/buildRuntime.sh
304312
shell: bash

.ocamlformat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
profile = default
2-
version = 0.26.2
2+
version = 0.27.0
33

44
field-space = tight-decl
55
break-cases = toplevel
@@ -9,3 +9,4 @@ space-around-arrays = false
99
space-around-lists = false
1010
space-around-records = false
1111
space-around-variants = false
12+
parse-docstrings = false

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Make sure you have [opam](https://opam.ocaml.org/doc/Install.html) installed on
4747
opam init
4848

4949
# Any recent OCaml version works as a development compiler
50-
opam switch create 5.2.1 # can also create local switch with opam switch create
50+
opam switch create 5.3.0 # can also create local switch with opam switch create
5151

5252
# Install dev dependencies from OPAM
5353
opam install . --deps-only --with-test --with-dev-setup -y

Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@ test-tools:
4040

4141
test-syntax:
4242
bash ./scripts/test_syntax.sh
43-
make reanalyze
4443
bash ./scripts/testok.sh
4544

4645
test-syntax-roundtrip:
4746
ROUNDTRIP_TEST=1 bash ./scripts/test_syntax.sh
48-
make reanalyze
4947
bash ./scripts/testok.sh
5048

5149
test-gentype:

analysis.opam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ license: "LGPL-3.0-or-later"
77
homepage: "https://github.com/rescript-lang/rescript-compiler"
88
bug-reports: "https://github.com/rescript-lang/rescript-compiler/issues"
99
depends: [
10-
"ocaml" {>= "4.10"}
11-
"cppo" {= "1.6.9"}
10+
"ocaml" {>= "4.14"}
11+
"cppo" {= "1.8.0"}
1212
"dune"
1313
]
1414
build: [

analysis/reanalyze/src/DeadCommon.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,8 @@ module Decl = struct
555555
let refIsBelow (pos : Lexing.position) =
556556
decl.pos.pos_fname <> pos.pos_fname
557557
|| decl.pos.pos_cnum < pos.pos_cnum
558-
&& (* not a function defined inside a function, e.g. not a callback *)
558+
&&
559+
(* not a function defined inside a function, e.g. not a callback *)
559560
decl.posEnd.pos_cnum < pos.pos_cnum
560561
in
561562
refs |> PosSet.exists refIsBelow

analysis/src/SignatureHelp.ml

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -553,44 +553,44 @@ let signatureHelp ~path ~pos ~currentFile ~debug ~allowForConstructorPayloads =
553553
let offset = ref 0 in
554554
Some
555555
(`InlineRecord
556-
(fields
557-
|> List.map (fun (field : field) ->
558-
let startOffset = !offset in
559-
let argText =
560-
Printf.sprintf "%s%s: %s" field.fname.txt
561-
(if field.optional then "?" else "")
562-
(Shared.typeToString
563-
(if field.optional then
564-
Utils.unwrapIfOption field.typ
565-
else field.typ))
566-
in
567-
let endOffset =
568-
startOffset + String.length argText
569-
in
570-
offset := endOffset + String.length ", ";
571-
(argText, field, (startOffset, endOffset)))))
556+
(fields
557+
|> List.map (fun (field : field) ->
558+
let startOffset = !offset in
559+
let argText =
560+
Printf.sprintf "%s%s: %s" field.fname.txt
561+
(if field.optional then "?" else "")
562+
(Shared.typeToString
563+
(if field.optional then
564+
Utils.unwrapIfOption field.typ
565+
else field.typ))
566+
in
567+
let endOffset =
568+
startOffset + String.length argText
569+
in
570+
offset := endOffset + String.length ", ";
571+
(argText, field, (startOffset, endOffset)))))
572572
| Args [(typ, _)] ->
573573
Some
574574
(`SingleArg
575-
( typ |> Shared.typeToString,
576-
docsForLabel ~file:full.file ~package:full.package
577-
~supportsMarkdownLinks typ ))
575+
( typ |> Shared.typeToString,
576+
docsForLabel ~file:full.file ~package:full.package
577+
~supportsMarkdownLinks typ ))
578578
| Args args ->
579579
let offset = ref 0 in
580580
Some
581581
(`TupleArg
582-
(args
583-
|> List.map (fun (typ, _) ->
584-
let startOffset = !offset in
585-
let argText = typ |> Shared.typeToString in
586-
let endOffset =
587-
startOffset + String.length argText
588-
in
589-
offset := endOffset + String.length ", ";
590-
( argText,
591-
docsForLabel ~file:full.file ~package:full.package
592-
~supportsMarkdownLinks typ,
593-
(startOffset, endOffset) ))))
582+
(args
583+
|> List.map (fun (typ, _) ->
584+
let startOffset = !offset in
585+
let argText = typ |> Shared.typeToString in
586+
let endOffset =
587+
startOffset + String.length argText
588+
in
589+
offset := endOffset + String.length ", ";
590+
( argText,
591+
docsForLabel ~file:full.file ~package:full.package
592+
~supportsMarkdownLinks typ,
593+
(startOffset, endOffset) ))))
594594
in
595595
let label =
596596
constructor.name ^ "("

compiler/bsb/bsb_exception.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ let print (fmt : Format.formatter) (x : error) =
4040
| Conflict_module (modname, dir1, dir2) ->
4141
Format.fprintf fmt
4242
"@{<error>Error:@} %s found in two directories: (%s, %s)\n\
43-
File names must be unique per project" modname dir1 dir2
43+
File names must be unique per project"
44+
modname dir1 dir2
4445
| No_implementation modname ->
4546
Format.fprintf fmt "@{<error>Error:@} %s does not have implementation file"
4647
modname
@@ -51,12 +52,14 @@ let print (fmt : Format.formatter) (x : error) =
5152
"File \"bsconfig.json\", line 1\n\
5253
@{<error>Error:@} package @{<error>%s@} is not found\n\
5354
It's the basic, required package. If you have it installed globally,\n\
54-
Please run `npm link rescript` to make it available" name
55+
Please run `npm link rescript` to make it available"
56+
name
5557
else
5658
Format.fprintf fmt
5759
"File \"bsconfig.json\", line 1\n\
5860
@{<error>Error:@} package @{<error>%s@} not found or built\n\
59-
- Did you install it?" name
61+
- Did you install it?"
62+
name
6063
| Json_config (pos, s) ->
6164
Format.fprintf fmt
6265
"File %S, line %d:\n\

compiler/bsb/bsb_ninja_check.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ let record ~(package_kind : Bsb_package_kind.t) ~per_proj_dir ~file
114114
record_global_atime buf Sys.executable_name;
115115
Ext_list.iter config.ppx_files (fun {name; args = _} ->
116116
try record_global_atime buf name
117-
with _ -> (* record the ppx files as a best effort *)
118-
());
117+
with _ ->
118+
(* record the ppx files as a best effort *)
119+
());
119120
let oc = open_out_bin file in
120121
Ext_buffer.output_buffer oc buf;
121122
close_out oc

0 commit comments

Comments
 (0)