Skip to content
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

infinite loop in presence of nonrec types #62

Open
agarwal opened this issue Sep 21, 2017 · 1 comment
Open

infinite loop in presence of nonrec types #62

agarwal opened this issue Sep 21, 2017 · 1 comment

Comments

@agarwal
Copy link

agarwal commented Sep 21, 2017

utop # #require "ppx_deriving_yojson";;

utop # type t = A | B [@@deriving yojson];;

utop # module M = struct type nonrec t = t [@@deriving yojson] end;;

utop # M.to_yojson A;;
(* never returns *)
^CInterrupted.

(* Work around by using different type name. *)
utop # module M = struct type u = t [@@deriving yojson] end;;

utop # M.u_to_yojson A;;
- : Yojson.Safe.json = `List [`String "A"]
@agarwal
Copy link
Author

agarwal commented Sep 21, 2017

Another way to see the problem:

utop # type t = {a:int};;

utop # type nonrec t = t [@@deriving yojson];;
type nonrec t = t
val to_yojson : t -> Yojson.Safe.json = <fun>
val of_yojson : Yojson.Safe.json -> t Ppx_deriving_yojson_runtime.error_or = <fun>

Last command shouldn't even compile since first definition of t lacks the corresponding derived functions.

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

No branches or pull requests

1 participant