OCaml5: move @ocaml.inline annotation on the `let`
What
OCaml5 reworks the warnings for annotations: let (v [@ocaml.inline]) is no longer valid, let[@ocaml.inline] v is.
Why
Our culprit is probably ocaml/ocaml!12451
Note that this also affect protocols 16 and 17, bit it should be addressed in a follow-up MR.
How
Simply move the annotation on the let instead of the value name.
Manually testing the MR
Try to compile this file with ocaml 4 and 5:
let[@ocaml.inline always] f x y = x + y
let (g [@ocaml.inline "always"]) = fun x y -> x + y
with ocaml 4.14:
$ ocamlc test_inline.ml
# Everything works smoothly
with ocaml 5:
$ <ocaml5-opam-switch/bin/>ocamlc test_inline.ml
File "test_inline.ml", line 2, characters 9-21:
2 | let (g [@ocaml.inline "always"]) = fun x y -> x + y
^^^^^^^^^^^^
Warning 53 [misplaced-attribute]: the "ocaml.inline" attribute cannot appear in this context
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR
Edited by Pierrick Couderc