twrongmapit.nim 658 B

123456789101112131415161718192021222324252627282930313233
  1. discard """
  2. output: "####"
  3. """
  4. # unfortunately our tester doesn't support multiple lines of compiler
  5. # error messages yet...
  6. # bug #1562
  7. type Foo* {.pure, final.} = object
  8. elt: float
  9. template defineOpAssign(T, op: untyped) {.immediate.} =
  10. proc op*(v: var T, w: T) {.inline.} =
  11. for i in 0..1:
  12. op(v.elt, w.elt)
  13. const ATTEMPT = 0
  14. when ATTEMPT == 0:
  15. # FAILS: defining `/=` with template calling template
  16. # ERROR about sem.nim line 144
  17. template defineOpAssigns(T: untyped) =
  18. mixin `/=`
  19. defineOpAssign(T, `/=`)
  20. defineOpAssigns(Foo)
  21. # bug #1543
  22. import sequtils
  23. (var i = @[""];i).applyIt(it)
  24. # now works:
  25. echo "##", i[0], "##"