summaryrefslogtreecommitdiff
path: root/tests/diagnostics
diff options
context:
space:
mode:
Diffstat (limited to 'tests/diagnostics')
-rw-r--r--tests/diagnostics/generic-constraint-equality-right-hand-side.slang36
-rw-r--r--tests/diagnostics/non-standard-extension.slang17
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/diagnostics/generic-constraint-equality-right-hand-side.slang b/tests/diagnostics/generic-constraint-equality-right-hand-side.slang
new file mode 100644
index 000000000..c49fe2035
--- /dev/null
+++ b/tests/diagnostics/generic-constraint-equality-right-hand-side.slang
@@ -0,0 +1,36 @@
+//TEST:SIMPLE(filecheck=CHECK):
+interface IGen<A>
+{
+ associatedtype TB;
+ int getVal();
+}
+
+interface Wrapper<A>
+{}
+
+struct Foo1<A> : IGen<A>
+{
+ typealias TB = Wrapper<A>; // `Wrapper<int>` also fails.
+ int val = 0;
+ int getVal()
+ {
+ return val;
+ }
+}
+
+struct Logic<A1, C1 : IGen<A1>>
+{
+ int val = 0;
+}
+
+extension<A, C1> Logic<A, C1>
+ where C1 : IGen<A>
+ //CHECK: ([[# @LINE+1]]): error 30404:
+ where C1.TB == Wrapper<int>
+{
+ [mutating]
+ void setVal(int dataIn)
+ {
+ val = dataIn;
+ }
+}
diff --git a/tests/diagnostics/non-standard-extension.slang b/tests/diagnostics/non-standard-extension.slang
new file mode 100644
index 000000000..d6a4350a4
--- /dev/null
+++ b/tests/diagnostics/non-standard-extension.slang
@@ -0,0 +1,17 @@
+//TEST:SIMPLE(filecheck=CHECK): -warnings-as-errors 30856
+
+interface ICompatibleWith<T> {}
+interface IBase {}
+struct INT : IBase {}
+struct FLOAT : IBase {}
+
+extension<EX : IBase> EX : ICompatibleWith<INT> {}
+extension<EY : IBase> EY : ICompatibleWith<FLOAT> {}
+
+struct VECTOR<T> {}
+
+// CHECK: ([[# @LINE+1]]): error 30856: the extension is non-standard
+extension<T, U : ICompatibleWith<T>> VECTOR<U> : ICompatibleWith<VECTOR<T>> {}
+
+void main()
+{} \ No newline at end of file