| 1 | open Core |
| 2 | |
| 3 | (* record wrapped in variant *) |
| 4 | type r = |
| 5 | { i : int |
| 6 | ; s : string |
| 7 | } |
| 8 | [@@deriving hash] |
| 9 | |
| 10 | type vr = |
| 11 | | A of r |
| 12 | | B |
| 13 | [@@deriving hash] |
| 14 | |
| 15 | let vr = A { i = 42; s = "hey" } |
| 16 | |
| 17 | (* inline record *) |
| 18 | type ir = |
| 19 | | A of |
| 20 | { i : int |
| 21 | ; s : string |
| 22 | } |
| 23 | | B |
| 24 | [@@deriving hash] |
| 25 | |
| 26 | let ir = A { i = 42; s = "hey" } |
| 27 | |
| 28 | let%test_unit "hash unchanged by use of inline records" = |
| 29 | [%test_eq: int] ([%hash: vr] vr) ([%hash: ir] ir) |
| 30 | ;; |