aboutsummaryrefslogtreecommitdiffhomepage
path: root/test-suite/success/Typeclasses.v
diff options
context:
space:
mode:
authorGravatar Matthieu Sozeau <mattam@mattam.org>2016-11-16 10:45:25 +0100
committerGravatar Matthieu Sozeau <mattam@mattam.org>2016-11-16 16:24:01 +0100
commit09fd1e8b5e810bae0e50ecd4901cd7c8f1464f4a (patch)
treefae1680206dc022cd52374934376cb43926059d2 /test-suite/success/Typeclasses.v
parent3a51aa7265f35dd3cbf3f7bff858d663e4406146 (diff)
Revert more of a477dc for good measure
We stop failing automatically on non-declared-class nested or toplevel subgoals as in 8.5, instead of the previous a477dc behavior of shelving those goals and failing if shelved goals remained at the end of resolution. It means typeclass resolution during refinement is closer to all:typeclasses eauto. Hints in typeclass_instances for non-declared classes can be used during resolution of _nested_ subgoals when it is fired from type-inference, toplevel goals considered in this case are still only classes (as in 8.5 and before). The code that triggers the restriction to only declared class subgoals is commented. Revert changes to test-suite, adding test for #5203, #5198 is fixed too. Add corresponding tests in the test-suite (that will break if we, e.g. disallow non-class subgoals) and update the refman accordingly.
Diffstat (limited to 'test-suite/success/Typeclasses.v')
-rw-r--r--test-suite/success/Typeclasses.v46
1 files changed, 40 insertions, 6 deletions
diff --git a/test-suite/success/Typeclasses.v b/test-suite/success/Typeclasses.v
index 5557ba837..f62427ef4 100644
--- a/test-suite/success/Typeclasses.v
+++ b/test-suite/success/Typeclasses.v
@@ -1,15 +1,28 @@
Module onlyclasses.
+(* In 8.6 we still allow non-class subgoals *)
Variable Foo : Type.
Variable foo : Foo.
Hint Extern 0 Foo => exact foo : typeclass_instances.
Goal Foo * Foo.
split. shelve.
Set Typeclasses Debug.
- Fail (unshelve typeclasses eauto); fail.
- typeclasses eauto with typeclass_instances.
- Unshelve. typeclasses eauto with typeclass_instances.
+ typeclasses eauto.
+ Unshelve. typeclasses eauto.
Qed.
+
+ Module RJung.
+ Class Foo (x : nat).
+
+ Instance foo x : x = 2 -> Foo x.
+ Hint Extern 0 (_ = _) => reflexivity : typeclass_instances.
+ Typeclasses eauto := debug.
+ Check (_ : Foo 2).
+
+
+ Fail Definition foo := (_ : 0 = 0).
+
+ End RJung.
End onlyclasses.
Module shelve_non_class_subgoals.
@@ -17,16 +30,36 @@ Module shelve_non_class_subgoals.
Variable foo : Foo.
Hint Extern 0 Foo => exact foo : typeclass_instances.
Class Bar := {}.
- Instance bar1 (f:Foo) : Bar.
+ Instance bar1 (f:Foo) : Bar := {}.
Typeclasses eauto := debug.
Set Typeclasses Debug Verbosity 2.
Goal Bar.
(* Solution has shelved subgoals (of non typeclass type) *)
- Fail typeclasses eauto.
+ typeclasses eauto.
Abort.
End shelve_non_class_subgoals.
+Module RefineVsNoTceauto.
+
+ Class Foo (A : Type) := foo : A.
+ Instance: Foo nat := { foo := 0 }.
+ Instance: Foo nat := { foo := 42 }.
+ Hint Extern 0 (_ = _) => refine eq_refl : typeclass_instances.
+ Goal exists (f : Foo nat), @foo _ f = 0.
+ Proof.
+ unshelve (notypeclasses refine (ex_intro _ _ _)).
+ Set Typeclasses Debug. Set Printing All.
+ all:once (typeclasses eauto).
+ Fail idtac. (* Check no subgoals are left *)
+ Undo 3.
+ (** In this case, the (_ = _) subgoal is not considered
+ by typeclass resolution *)
+ refine (ex_intro _ _ _). Fail reflexivity.
+ Abort.
+
+End RefineVsNoTceauto.
+
Module Leivantex2PR339.
(** Was a bug preventing to find hints associated with no pattern *)
Class Bar := {}.
@@ -34,8 +67,9 @@ Module Leivantex2PR339.
Hint Extern 0 => exact True : typeclass_instances.
Typeclasses eauto := debug.
Goal Bar.
- Fail typeclasses eauto.
Set Typeclasses Debug Verbosity 2.
+ typeclasses eauto. (* Relies on resolution of a non-class subgoal *)
+ Undo 1.
typeclasses eauto with typeclass_instances.
Qed.
End Leivantex2PR339.