summary refs log tree commit diff stats
path: root/tests/template/twrongmapit.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/template/twrongmapit.nim')
-rw-r--r--tests/template/twrongmapit.nim30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/template/twrongmapit.nim b/tests/template/twrongmapit.nim
new file mode 100644
index 000000000..2d53d03f5
--- /dev/null
+++ b/tests/template/twrongmapit.nim
@@ -0,0 +1,30 @@
+discard """
+  joinable: false
+"""
+
+# bug #1562
+type Foo* {.pure, final.} = object
+  elt: float
+
+template defineOpAssign(T, op: untyped) =
+  proc `op`*(v: var T, w: T) {.inline.} =
+    for i in 0..1:
+      `op`(v.elt, w.elt)
+
+const ATTEMPT = 0
+
+when ATTEMPT == 0:
+  # FAILS: defining `/=` with template calling template
+  # ERROR about sem.nim line 144
+  template defineOpAssigns(T: untyped) =
+    mixin `/=`
+    defineOpAssign(T, `/=`)
+
+  defineOpAssigns(Foo)
+
+# bug #1543
+import sequtils
+
+(var i = @[""];i).applyIt(it)
+# now works:
+doAssert i[0] == ""