Proto/Alpha: OCaml5: add annotation for parse_instr to typecheck
What & why
There is a regression with OCaml 5.0+ that makes some GADT not typecheck anymore without a bit of help.
How
Simply annotate the right function with the return type of parse_instr, as it seems the type equality is lost somewhere in the process.
It unfortunately applies to all the protocols starting proto_010, for which we will also need to find a solution.
Manually testing the MR
From the ocaml5 branch (and switch), checkout on 2e35c5b4998 that is the top branch without this commit and try to typecheck proto_alpha:
dune @src/proto_alpha/lib_protocol/check
which will result in a cryptic typechecking error:
File "src/proto_alpha/lib_protocol/script_ir_translator.ml", lines 3027-3034, characters 10-55:
3027 | ..........record_trace_eval
3028 | invalid_map_body
3029 | (let* Eq, ctxt = stack_eq loc ctxt 1 aft_rest rest in
3030 | let* opt_ty = option_t loc ret in
3031 | let final_stack = Item_t (opt_ty, rest) in
3032 | let body = kibody.instr.apply (IHalt loc) in
3033 | let apply k = IOpt_map {loc; body; k} in
3034 | typed_no_lwt ctxt loc {apply} final_stack)
Error: This expression has type
"((a, s) judgement * context, error trace) result"
but an expression was expected of type "'a"
This instance of "$0 * $1" is ambiguous:
it would escape the scope of its equation
Type "result" is abstract because no corresponding cmi file was found
in path.
CHerry-pick the commit, run it again, and it should work properly.
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