summary refs log tree commit diff stats
path: root/tests/concepts
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2017-03-24 14:33:53 +0200
committerZahary Karadjov <zahary@gmail.com>2017-03-24 17:07:30 +0200
commit79881bfce0970098b6dc38f6fbb18a86b54c7fad (patch)
tree8c435247ade20abcf1f32bd67bfa0b162937573f /tests/concepts
parente3500ba4581a1a75bba474eb5dbf68676399514a (diff)
downloadNim-79881bfce0970098b6dc38f6fbb18a86b54c7fad.tar.gz
close #976
Diffstat (limited to 'tests/concepts')
-rw-r--r--tests/concepts/t976.nim32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/concepts/t976.nim b/tests/concepts/t976.nim
new file mode 100644
index 000000000..cc0bbdc59
--- /dev/null
+++ b/tests/concepts/t976.nim
@@ -0,0 +1,32 @@
+import macros
+
+type
+  int1 = distinct int
+  int2 = distinct int
+
+  int1g = concept x
+    x is int1
+
+  int2g = concept x
+    x is int2
+
+proc take[T: int1g](value: int1) =
+  when T is int2:
+    static: error("killed in take(int1)")
+
+proc take[T: int2g](vale: int2) =
+  when T is int1:
+    static: error("killed in take(int2)")
+
+var i1: int1 = 1.int1
+var i2: int2 = 2.int2
+
+take[int1](i1)
+take[int2](i2)
+
+template reject(e) =
+  static: assert(not compiles(e))
+
+reject take[string](i2)
+reject take[int1](i2)
+