Skip to content

Conversation

@brandonzstride
Copy link

Summary

Updates landmarks-ppx for compatibility with ppxlib 0.36.0, which changed the internal AST representation to OCaml 5.2.

Breaking Change

Requires ppxlib >= 0.36.0.

This version is not compatible with ppxlib < 0.36.0 due to AST representation change.

Notes

Changes are localized to ppx/mapper.ml.

I did simple rewrites of the arity function (line 177) and wrap_landmark_method function (line 204) to work with the new Pexp_function AST node and preserve landmarks behavior as much as possible.

Critical fix: keep pvb_constraint when rebuilding value binding (line 272). This allows the following minimal examples to compile because of their necessary type annotations.

type _ t =
  | A : int t
  | B : bool t

let f : type a. a t -> bool = function
  | A -> true
  | B -> false

And

type empty = private | 

let absurd : 'a. empty -> 'a = function _ -> .

Testing

I verify that the above examples compile with instrumentation. I also profile a simple fib program using function to check that output is identical previous releases. I then instrument a small project (about 2000 lines) with several modules, and to my eye, the output is as expected. That small project uses a menhir parser (whose outputted code can be instrumented with landmarks-ppx) and polymorphic recursion with GADTs, for example, so it reasonably covers a few features I might expect to break if this ppx upgrade was buggy.

All of the above testing was done with the --auto flag to ppx annotate all functions.

This code (from README.md) still fails to compile:

let test = (fun x -> x)[@landmark "test"]
in test "string", test 1

- Use new Pexp_function AST node
- Keep pvb_constraint in value binding for polymorphic function type checking
- Requires ppxlib >= 0.36.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant