summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2017-04-16 13:42:33 +0300
committerZahary Karadjov <zahary@gmail.com>2017-04-16 13:42:33 +0300
commit4da8536701516f88cf2a04152abb8d8a276042d6 (patch)
tree589043f63bdaac5cc64a4cc2511de052c89e00b4 /tests
parentdfbafff2e7cbadd28cade976520f86848a00a7c9 (diff)
downloadNim-4da8536701516f88cf2a04152abb8d8a276042d6.tar.gz
fix compilation regression in alea
Diffstat (limited to 'tests')
-rw-r--r--tests/concepts/tconceptinclosure.nim33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/concepts/tconceptinclosure.nim b/tests/concepts/tconceptinclosure.nim
new file mode 100644
index 000000000..ccd19d201
--- /dev/null
+++ b/tests/concepts/tconceptinclosure.nim
@@ -0,0 +1,33 @@
+discard """
+  output: "10\n20"
+"""
+
+type
+  FonConcept = concept x
+    x.x is int
+
+  Implementation = object
+    x: int
+
+  Closure = object
+    f: proc()
+
+proc f1(x: FonConcept): Closure =
+  result.f = proc () =
+    echo x.x
+
+proc f2(x: FonConcept): Closure =
+  result.f = proc () =
+    echo x.x
+
+let x = Implementation(x: 10)
+let y = Implementation(x: 20)
+
+let a = x.f1
+let b = x.f2
+let c = x.f1
+let d = y.f2
+
+a.f()
+d.f()
+