Skip to content

Restore compatibility with OCaml 4.14 #6926

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 1 commit into from
Jul 30, 2024
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
3 changes: 2 additions & 1 deletion jscomp/ext/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
(wrapped false)
(preprocess
(action
(run %{bin:cppo} %{env:CPPO_FLAGS=} %{input-file})))
(run %{bin:cppo} -V OCAML:%{ocaml_version} %{env:CPPO_FLAGS=}
%{input-file})))
(flags
(:standard -w +a-4-42-40-9-48-70))
(foreign_stubs
Expand Down
11 changes: 10 additions & 1 deletion jscomp/ext/js_reserved_map.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

module STbl = struct
include Hashtbl.Make (String)
#if OCAML_VERSION >= (5, 0, 0)
include Hashtbl.Make (String)
#else
module StringHash : Hashtbl.HashedType with type t = string = struct
type t = string
let equal = String.equal
let hash = Hashtbl.hash (* polymorphic hash function *)
end
include Hashtbl.Make (StringHash)
#endif

let of_array arr =
let tbl = create (Array.length arr) in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great
One could also always redefine compare.
But conditional compilation depending on compiler version is also fine as it does not add much complexity.

Expand Down