summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2017-03-24 16:21:14 +0200
committerZahary Karadjov <zahary@gmail.com>2017-03-24 17:07:30 +0200
commit78ca4f6be4980b6f37b705ce4fd390976f044c4e (patch)
tree65ad9fd5281d0515642a7b29852ad3e9600cfdd4 /tests
parentbec7f9398fe3b90089d4ffb8f0da5ec8574a891d (diff)
downloadNim-78ca4f6be4980b6f37b705ce4fd390976f044c4e.tar.gz
close #3330
Diffstat (limited to 'tests')
-rw-r--r--tests/concepts/t3330.nim41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/concepts/t3330.nim b/tests/concepts/t3330.nim
new file mode 100644
index 000000000..04add2b6f
--- /dev/null
+++ b/tests/concepts/t3330.nim
@@ -0,0 +1,41 @@
+discard """
+errormsg: "type mismatch: got (Bar[system.int])"
+nimout: '''
+t3330.nim(40, 4) Error: type mismatch: got (Bar[system.int])
+but expected one of: 
+proc test(foo: Foo[int])
+t3330.nim(25, 8) Hint: Non-matching candidates for add(k, string, T)
+proc add[T](x: var seq[T]; y: T)
+proc add(result: var string; x: float)
+proc add(x: var string; y: string)
+proc add(x: var string; y: cstring)
+proc add(x: var string; y: char)
+proc add(result: var string; x: int64)
+proc add[T](x: var seq[T]; y: openArray[T])
+
+t3330.nim(25, 8) template/generic instantiation from here
+t3330.nim(32, 6) Foo: 'bar.value' cannot be assigned to
+t3330.nim(25, 8) template/generic instantiation from here
+t3330.nim(33, 6) Foo: 'bar.x' cannot be assigned to
+'''
+"""
+
+type
+  Foo[T] = concept k
+    add(k, string, T)
+
+  Bar[T] = object
+    value: T
+    x: string
+
+proc add[T](bar: Bar[T], x: string, val: T) =
+  bar.value = val
+  bar.x = x
+
+proc test(foo: Foo[int]) =
+  foo.add("test", 42)
+  echo(foo.x)
+
+var bar = Bar[int]()
+bar.test()
+