Skip to content

Ocaml 5.3 #7294

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

Merged
merged 6 commits into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 1 deletion .devcontainer/postCreate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

# For IDE support, install the OCaml language server
Expand Down
22 changes: 15 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,32 +87,34 @@ jobs:
matrix:
include:
- os: ubuntu-24.04 # x64
ocaml_compiler: ocaml-variants.5.2.1+options,ocaml-option-static
ocaml_compiler: ocaml-variants.5.3.0+options,ocaml-option-static
upload_binaries: true
upload_libs: true
- os: ubuntu-24.04-arm # ARM
ocaml_compiler: ocaml-variants.5.2.1+options,ocaml-option-static
ocaml_compiler: ocaml-variants.5.3.0+options,ocaml-option-static
upload_binaries: true
# Build the playground compiler and run the benchmarks on the fastest runner
build_playground: true
benchmarks: true
- os: macos-13 # x64
ocaml_compiler: 5.2.1
ocaml_compiler: 5.3.0
upload_binaries: true
- os: macos-14 # ARM
ocaml_compiler: 5.2.1
ocaml_compiler: 5.3.0
upload_binaries: true
- os: windows-latest
ocaml_compiler: 5.2.1
ocaml_compiler: 5.3.0
upload_binaries: true

# Verify that the compiler still builds with older OCaml versions
- os: ubuntu-24.04
ocaml_compiler: ocaml-variants.5.2.1+options,ocaml-option-static
# Reanalyze does not work on OCaml 5.3.0 anymore, therefore run it on 5.2.1
run_reanalyze: true
- os: ubuntu-24.04
ocaml_compiler: ocaml-variants.5.0.0+options,ocaml-option-static
- os: ubuntu-24.04
ocaml_compiler: ocaml-variants.4.14.2+options,ocaml-option-static
- os: ubuntu-24.04
ocaml_compiler: ocaml-variants.4.13.0+options,ocaml-option-static

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

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

- name: "Syntax: Run reanalyze"
if: matrix.run_reanalyze
run: |
opam install reanalyze
opam exec -- make reanalyze

- name: Build runtime/stdlib
run: ./scripts/buildRuntime.sh
shell: bash
Expand Down
3 changes: 2 additions & 1 deletion .ocamlformat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
profile = default
version = 0.26.2
version = 0.27.0

field-space = tight-decl
break-cases = toplevel
Expand All @@ -9,3 +9,4 @@ space-around-arrays = false
space-around-lists = false
space-around-records = false
space-around-variants = false
parse-docstrings = false
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Make sure you have [opam](https://opam.ocaml.org/doc/Install.html) installed on
opam init

# Any recent OCaml version works as a development compiler
opam switch create 5.2.1 # can also create local switch with opam switch create
opam switch create 5.3.0 # can also create local switch with opam switch create

# Install dev dependencies from OPAM
opam install . --deps-only --with-test --with-dev-setup -y
Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ test-tools:

test-syntax:
bash ./scripts/test_syntax.sh
make reanalyze
bash ./scripts/testok.sh

test-syntax-roundtrip:
ROUNDTRIP_TEST=1 bash ./scripts/test_syntax.sh
make reanalyze
bash ./scripts/testok.sh

test-gentype:
Expand Down
4 changes: 2 additions & 2 deletions analysis.opam
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ license: "LGPL-3.0-or-later"
homepage: "https://github.com/rescript-lang/rescript-compiler"
bug-reports: "https://github.com/rescript-lang/rescript-compiler/issues"
depends: [
"ocaml" {>= "4.10"}
"cppo" {= "1.6.9"}
"ocaml" {>= "4.14"}
"cppo" {= "1.8.0"}
"dune"
]
build: [
Expand Down
3 changes: 2 additions & 1 deletion analysis/reanalyze/src/DeadCommon.ml
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,8 @@ module Decl = struct
let refIsBelow (pos : Lexing.position) =
decl.pos.pos_fname <> pos.pos_fname
|| decl.pos.pos_cnum < pos.pos_cnum
&& (* not a function defined inside a function, e.g. not a callback *)
&&
(* not a function defined inside a function, e.g. not a callback *)
decl.posEnd.pos_cnum < pos.pos_cnum
in
refs |> PosSet.exists refIsBelow
Expand Down
62 changes: 31 additions & 31 deletions analysis/src/SignatureHelp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -553,44 +553,44 @@ let signatureHelp ~path ~pos ~currentFile ~debug ~allowForConstructorPayloads =
let offset = ref 0 in
Some
(`InlineRecord
(fields
|> List.map (fun (field : field) ->
let startOffset = !offset in
let argText =
Printf.sprintf "%s%s: %s" field.fname.txt
(if field.optional then "?" else "")
(Shared.typeToString
(if field.optional then
Utils.unwrapIfOption field.typ
else field.typ))
in
let endOffset =
startOffset + String.length argText
in
offset := endOffset + String.length ", ";
(argText, field, (startOffset, endOffset)))))
(fields
|> List.map (fun (field : field) ->
let startOffset = !offset in
let argText =
Printf.sprintf "%s%s: %s" field.fname.txt
(if field.optional then "?" else "")
(Shared.typeToString
(if field.optional then
Utils.unwrapIfOption field.typ
else field.typ))
in
let endOffset =
startOffset + String.length argText
in
offset := endOffset + String.length ", ";
(argText, field, (startOffset, endOffset)))))
| Args [(typ, _)] ->
Some
(`SingleArg
( typ |> Shared.typeToString,
docsForLabel ~file:full.file ~package:full.package
~supportsMarkdownLinks typ ))
( typ |> Shared.typeToString,
docsForLabel ~file:full.file ~package:full.package
~supportsMarkdownLinks typ ))
| Args args ->
let offset = ref 0 in
Some
(`TupleArg
(args
|> List.map (fun (typ, _) ->
let startOffset = !offset in
let argText = typ |> Shared.typeToString in
let endOffset =
startOffset + String.length argText
in
offset := endOffset + String.length ", ";
( argText,
docsForLabel ~file:full.file ~package:full.package
~supportsMarkdownLinks typ,
(startOffset, endOffset) ))))
(args
|> List.map (fun (typ, _) ->
let startOffset = !offset in
let argText = typ |> Shared.typeToString in
let endOffset =
startOffset + String.length argText
in
offset := endOffset + String.length ", ";
( argText,
docsForLabel ~file:full.file ~package:full.package
~supportsMarkdownLinks typ,
(startOffset, endOffset) ))))
in
let label =
constructor.name ^ "("
Expand Down
9 changes: 6 additions & 3 deletions compiler/bsb/bsb_exception.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ let print (fmt : Format.formatter) (x : error) =
| Conflict_module (modname, dir1, dir2) ->
Format.fprintf fmt
"@{<error>Error:@} %s found in two directories: (%s, %s)\n\
File names must be unique per project" modname dir1 dir2
File names must be unique per project"
modname dir1 dir2
| No_implementation modname ->
Format.fprintf fmt "@{<error>Error:@} %s does not have implementation file"
modname
Expand All @@ -51,12 +52,14 @@ let print (fmt : Format.formatter) (x : error) =
"File \"bsconfig.json\", line 1\n\
@{<error>Error:@} package @{<error>%s@} is not found\n\
It's the basic, required package. If you have it installed globally,\n\
Please run `npm link rescript` to make it available" name
Please run `npm link rescript` to make it available"
name
else
Format.fprintf fmt
"File \"bsconfig.json\", line 1\n\
@{<error>Error:@} package @{<error>%s@} not found or built\n\
- Did you install it?" name
- Did you install it?"
name
| Json_config (pos, s) ->
Format.fprintf fmt
"File %S, line %d:\n\
Expand Down
5 changes: 3 additions & 2 deletions compiler/bsb/bsb_ninja_check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ let record ~(package_kind : Bsb_package_kind.t) ~per_proj_dir ~file
record_global_atime buf Sys.executable_name;
Ext_list.iter config.ppx_files (fun {name; args = _} ->
try record_global_atime buf name
with _ -> (* record the ppx files as a best effort *)
());
with _ ->
(* record the ppx files as a best effort *)
());
let oc = open_out_bin file in
Ext_buffer.output_buffer oc buf;
close_out oc
Expand Down
3 changes: 2 additions & 1 deletion compiler/bsb/bsb_ninja_gen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ let emit_bsc_lib_includes (bs_dependencies : Bsb_config_types.dependencies)
let all_includes source_dirs =
source_dirs
@ Ext_list.map bs_dependencies (fun x -> x.package_install_path)
@ (* for external includes, if it is absolute path, leave it as is
@
(* for external includes, if it is absolute path, leave it as is
for relative path './xx', we need '../.././x' since we are in
[lib/bs], [build] is different from merlin though
*)
Expand Down
5 changes: 3 additions & 2 deletions compiler/bsb/bsb_parse_sources.ml
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,9 @@ and parse_sources (cxt : cxt) (sources : Ext_json_types.t) =
| Arr file_groups -> parsing_arr_sources cxt file_groups.content
| _ -> parsing_single_source cxt sources

let scan ~package_kind ~root ~cut_generators ~(* ~namespace *)
ignored_dirs x : t =
let scan ~package_kind ~root ~cut_generators
~(* ~namespace *)
ignored_dirs x : t =
parse_sources
{
ignored_dirs;
Expand Down
5 changes: 4 additions & 1 deletion compiler/bsb_helper/bsb_db_decode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ and decode_single (x : string) (offset : cursor) : group =
let modules = decode_modules x offset module_number in
let dir_info_offset = !offset in
let module_info_offset = String.index_from x dir_info_offset '\n' + 1 in
let dir_length = Char.code x.[module_info_offset] - 48 (* Char.code '0'*) in
let dir_length =
Char.code x.[module_info_offset] - 48
(* Char.code '0'*)
in
offset := module_info_offset + 1 + (dir_length * module_number) + 1;
Group {modules; dir_info_offset; module_info_offset; dir_length})
else Dummy
Expand Down
3 changes: 2 additions & 1 deletion compiler/core/js_analyzer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ let free_variables (stats : idents_stats) =
| Fun {env}
(* a optimization to avoid walking into function again
if it's already comuted
*) ->
*)
->
stats.used_idents <-
Set_ident.union (Js_fun_env.get_unbounded env) stats.used_idents
| _ -> super.expression self exp);
Expand Down
14 changes: 8 additions & 6 deletions compiler/core/js_cmj_format.ml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type cmj_value = {
(** Either constant or closed functor *)
}

type effect = string option
type effect_ = string option

let single_na = Single Lam_arity.na

Expand All @@ -52,7 +52,7 @@ type t = {
case: Ext_js_file_kind.case;
}

let make ~(values : cmj_value Map_string.t) ~effect ~package_spec ~case : t =
let make ~(values : cmj_value Map_string.t) ~effect_ ~package_spec ~case : t =
{
values =
Map_string.to_sorted_array_with_f values (fun k v ->
Expand All @@ -61,7 +61,7 @@ let make ~(values : cmj_value Map_string.t) ~effect ~package_spec ~case : t =
arity = v.arity;
persistent_closed_lambda = v.persistent_closed_lambda;
});
pure = effect = None;
pure = effect_ = None;
package_spec;
case;
}
Expand Down Expand Up @@ -113,7 +113,7 @@ let get_result mid_val =
match mid_val.persistent_closed_lambda with
| Some
(Lconst
(Const_js_null | Const_js_undefined _ | Const_js_true | Const_js_false))
(Const_js_null | Const_js_undefined _ | Const_js_true | Const_js_false))
| None ->
mid_val
| Some _ ->
Expand All @@ -131,8 +131,10 @@ let rec binary_search_aux arr lo hi (key : string) =
let lo_val = Array.unsafe_get arr lo in
if lo_val.name = key then get_result lo_val else not_found key
else binary_search_aux arr lo mid key
else if (* a[lo] =< a[mid] < key <= a[hi] *)
lo = mid then
else if
(* a[lo] =< a[mid] < key <= a[hi] *)
lo = mid
then
let hi_val = Array.unsafe_get arr hi in
if hi_val.name = key then get_result hi_val else not_found key
else binary_search_aux arr mid hi key
Expand Down
4 changes: 2 additions & 2 deletions compiler/core/js_cmj_format.mli
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type cmj_value = {
persistent_closed_lambda: Lam.t option; (* Either constant or closed functor *)
}

type effect = string option
type effect_ = string option

type keyed_cmj_value = {
name: string;
Expand All @@ -69,7 +69,7 @@ type t = {

val make :
values:cmj_value Map_string.t ->
effect:effect ->
effect_:effect_ ->
package_spec:Js_packages_info.t ->
case:Ext_js_file_kind.case ->
t
Expand Down
11 changes: 6 additions & 5 deletions compiler/core/js_dump.ml
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ and pp_function ~return_unit ~async ~is_method ?directive cxt (f : P.t)
since it can be either [int] or [string]
*)
and pp_one_case_clause :
'a. _ -> P.t -> (P.t -> 'a -> unit) -> 'a * J.case_clause -> _ =
'a. _ -> P.t -> (P.t -> 'a -> unit) -> 'a * J.case_clause -> _ =
fun cxt f pp_cond
(switch_case, ({switch_body; should_break; comment} : J.case_clause)) ->
P.newline f;
Expand Down Expand Up @@ -467,8 +467,7 @@ and pp_one_case_clause :
cxt

and loop_case_clauses :
'a. cxt -> P.t -> (P.t -> 'a -> unit) -> ('a * J.case_clause) list -> cxt
=
'a. cxt -> P.t -> (P.t -> 'a -> unit) -> ('a * J.case_clause) list -> cxt =
fun cxt f pp_cond cases ->
Ext_list.fold_left cases cxt (fun acc x -> pp_one_case_clause acc f pp_cond x)

Expand Down Expand Up @@ -693,7 +692,8 @@ and expression_desc cxt ~(level : int) f x : cxt =
{[ 0. - x ]}
{[ 0.00 - x ]}
{[ 0.000 - x ]}
*) ->
*)
->
P.cond_paren_group f (level > 13) (fun _ ->
P.string f
(match desc with
Expand Down Expand Up @@ -1214,7 +1214,8 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt =
semi f;
cxt)
(* There MUST be a space between the return and its
argument. A line return will not work *))
argument. A line return will not work *)
)
| Int_switch (e, cc, def) ->
P.string f L.switch;
P.space f;
Expand Down
Loading
Loading