summary refs log tree commit diff stats
path: root/tests/generics/tparam_binding.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-05-16 17:32:18 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-05-16 17:32:18 +0200
commit503f7806765f0cc6f072f578e272d12d3f9cce56 (patch)
treef6ad4a0cdf637ae9335f73cae482b3deb36fb353 /tests/generics/tparam_binding.nim
parent224eec595a6112c7aa3a4c06afacc99167580464 (diff)
parent3e52bb6535a70339cf4a15123be09916ef0c31f6 (diff)
downloadNim-503f7806765f0cc6f072f578e272d12d3f9cce56.tar.gz
Merge branch 'zahary' into araq2
Diffstat (limited to 'tests/generics/tparam_binding.nim')
-rw-r--r--tests/generics/tparam_binding.nim28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/generics/tparam_binding.nim b/tests/generics/tparam_binding.nim
new file mode 100644
index 000000000..643e9b226
--- /dev/null
+++ b/tests/generics/tparam_binding.nim
@@ -0,0 +1,28 @@
+discard """
+  errormsg: "got (ref Matrix[2, 2, system.float], ref Matrix[2, 1, system.float])"
+  line: 27
+"""
+
+type
+  Matrix[M,N: static[int]; T: SomeReal] = distinct array[0..(M*N - 1), T]
+
+let a = new Matrix[2,2,float]
+let b = new Matrix[2,1,float]
+
+proc foo[M,N: static[int],T](a: ref Matrix[M, N, T], b: ref Matrix[M, N, T])=
+  discard
+
+foo(a, a)
+
+proc bar[M,N: static[int],T](a: ref Matrix[M, M, T], b: ref Matrix[M, N, T])=
+  discard
+
+bar(a, b)
+bar(a, a)
+
+proc baz[M,N: static[int],T](a: ref Matrix[N, N, T], b: ref Matrix[M, N, T])=
+  discard
+
+baz(a, a)
+baz(a, b)
+