Skip to content

Commit

Permalink
Bias the mapping from magic to version towards the current version
Browse files Browse the repository at this point in the history
When mapping from magic numbers to versions, first check whether it is
the current version, which is probably the most common case
It has the added benefit that, when the mapping is ambiguous (mostly
between the latest stable release and the development version), this
strategy makes the good choice for the test suite

Signed-off-by: Samuel Hym <[email protected]>
  • Loading branch information
shym committed Apr 3, 2023
1 parent 369268b commit 2279e38
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ unreleased
- Fix failure of 'lift_map_with_context' in traverse by compile-time
evaluation of 'fst' and 'snd' (#390, @smuenzel)

- Bias the mapping from magic to version towards the current version,
as it is usually the common case and it helps when magic numbers are
ambiguous (such as on development versions) (#409, @shym)

0.29.1 (14/02/2023)
------------------

Expand Down
7 changes: 6 additions & 1 deletion ast/versions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -577,5 +577,10 @@ module Find_version = struct
else
loop tail
in
loop all_versions
(* First check whether it could be the current version, probably
the most common use case.
This bias towards the current version also provides a way to
choose wisely between, say, `trunk` and the latest stable
release, for which the magic numbers are not distinguished *)
loop @@ ((module OCaml_current : OCaml_version) :: all_versions)
end

0 comments on commit 2279e38

Please sign in to comment.