From 22bf4efd61b916abc81e41bbe70428e534dd0013 Mon Sep 17 00:00:00 2001 From: charguer Date: Tue, 19 Dec 2017 16:13:35 +0100 Subject: allow Prop as source for coercions --- test-suite/success/coercions.v | 25 +++++++++++++++++++++++++ vernac/class.ml | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/test-suite/success/coercions.v b/test-suite/success/coercions.v index 9b11bc011c..d4fa132d17 100644 --- a/test-suite/success/coercions.v +++ b/test-suite/success/coercions.v @@ -131,3 +131,28 @@ Local Coercion l2v2 : list >-> vect. Fail Check (fun l : list (T1 * T1) => (l : vect _ _)). Check (fun l : list (T1 * T1) => (l2v2 l : vect _ _)). Section what_we_could_do. + + +(** Unit test for Prop as source class *) + +Module TestPropAsSourceCoercion. + + Parameter heap : Prop. + + Parameter heap_empty : heap. + + Definition hprop := heap -> Prop. + + Coercion hpure (P:Prop) : hprop := fun h => h = heap_empty /\ P. + + Parameter heap_single : nat -> nat -> hprop. + + Parameter hstar : hprop -> hprop -> hprop. + + Notation "H1 \* H2" := (hstar H1 H2) (at level 69). + + Definition test := heap_single 4 5 \* (5 <> 4) \* heap_single 2 4 \* (True). + + (* Print test. -- reveals [hpure] coercions *) + +End TestPropAsSourceCoercion. \ No newline at end of file diff --git a/vernac/class.ml b/vernac/class.ml index cc676af1b4..59d9331087 100644 --- a/vernac/class.ml +++ b/vernac/class.ml @@ -225,7 +225,7 @@ let build_id_coercion idf_opt source poly = ConstRef kn let check_source = function -| Some (CL_FUN|CL_SORT as s) -> raise (CoercionError (ForbiddenSourceClass s)) +| Some (CL_FUN as s) -> raise (CoercionError (ForbiddenSourceClass s)) | _ -> () (* -- cgit v1.2.3