summary refs log tree commit diff stats
path: root/tests/template/twrongmapit.nim
blob: df695fcd62aee041448f3c889cb8edfb3fdf4e23 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
discard """
  output: "####"
"""
# unfortunately our tester doesn't support multiple lines of compiler
# error messages yet...

# bug #1562
type Foo* {.pure, final.} = object
  elt: float

template defineOpAssign(T: expr, op: expr) {.immediate.} =
  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: expr) {.immediate.} =
    mixin `/=`
    defineOpAssign(T, `/=`)

  defineOpAssigns(Foo)

# bug #1543
import sequtils

(var i = @[""];i).applyIt(it)
# now works:
echo "##", i[0], "##"