diff --git a/src/ppx_deriving_yojson.ml b/src/ppx_deriving_yojson.ml index 7236cc4..1a611c9 100644 --- a/src/ppx_deriving_yojson.ml +++ b/src/ppx_deriving_yojson.ml @@ -300,6 +300,11 @@ and desu_expr_of_only_typ ~path typ = raise_errorf ~loc:ptyp_loc "%s cannot be derived for %s" deriver (Ppx_deriving.string_of_core_type typ) +(* TODO: Do not wrap runtime around [@default ...]. + We do currently and for instance the following doesn't currently work: + module List = struct let x = [1; 2] end + type t = {field : int list [@default List.x]} [@@deriving to_yojson] +*) let wrap_runtime decls = Ppx_deriving.sanitize ~module_:(Lident "Ppx_deriving_yojson_runtime") decls diff --git a/src_test/test_ppx_yojson.ml b/src_test/test_ppx_yojson.ml index 21212f6..4849db2 100644 --- a/src_test/test_ppx_yojson.ml +++ b/src_test/test_ppx_yojson.ml @@ -505,6 +505,22 @@ let test_int_redefined ctxt = let expected = `Int 1 in assert_equal ~ctxt ~printer:show_json expected M.x +(* TODO: Make this work *) +(* +let test_list_redefined ctxt = + let module M = struct + type redef_list = + | [] + | (::) of int * int + + type t = {field : int list} [@@deriving to_yojson] + let x = {field = List.([1;2])} + end + in + let expected = `List [`Int 1; `Int 2] in + assert_equal ~ctxt ~printer:show_json expected M.x +*) + let test_equality_redefined ctxt = let module M = struct module Pervasives = struct