aboutsummaryrefslogtreecommitdiff
path: root/test-suite
diff options
context:
space:
mode:
authorMatthieu Sozeau2018-11-28 17:10:02 +0100
committerMatthieu Sozeau2018-11-28 17:10:02 +0100
commit320f8c4503293b37c852548e4d19ff4dd1c191cb (patch)
tree9d306d01b8ef00d8b87615259ea09fa82b568ad8 /test-suite
parent2e68697327f6f8a7f365ba3474a3f1a04ca4a621 (diff)
parent23fcb09d934bf77fe58f232d2c246a81fc76591f (diff)
Merge PR #9015: [Typeclasses] Warn when RHS of `:>` is not a class
Diffstat (limited to 'test-suite')
-rw-r--r--test-suite/bugs/closed/bug_9014.v19
1 files changed, 19 insertions, 0 deletions
diff --git a/test-suite/bugs/closed/bug_9014.v b/test-suite/bugs/closed/bug_9014.v
new file mode 100644
index 0000000000..c1fdd04a65
--- /dev/null
+++ b/test-suite/bugs/closed/bug_9014.v
@@ -0,0 +1,19 @@
+(* A type, not a class *)
+Variant T := mkT.
+
+(* In records, :> declares a coercion *)
+Record R := { t_of_r :> T }.
+Check forall r : R, r = r :> T.
+
+(* A class *)
+Class A := { p : Prop }.
+(* A sub-class *)
+Class B := { a_of_b :> A ; t_of_b :> T }.
+(* The sub-instance is automatically inferred due to :> for a_of_b *)
+Check forall b : B, p.
+(* No coercion is introduced by :> in t_of_b *)
+Fail Check forall b : B, b = b :> T.
+
+(* Using :> when the RHS is not a class produces a “not-a-class” warning. *)
+Set Warnings "+not-a-class".
+Fail Class B' := { a_of_b' :> A ; t_of_b' :> T }.