twrongmapit.nim 553 B

12345678910111213141516171819202122232425262728293031
  1. discard """
  2. joinable: false
  3. """
  4. # bug #1562
  5. type Foo* {.pure, final.} = object
  6. elt: float
  7. template defineOpAssign(T, op: untyped) =
  8. proc `op`*(v: var T, w: T) {.inline.} =
  9. for i in 0..1:
  10. `op`(v.elt, w.elt)
  11. const ATTEMPT = 0
  12. when ATTEMPT == 0:
  13. # FAILS: defining `/=` with template calling template
  14. # ERROR about sem.nim line 144
  15. template defineOpAssigns(T: untyped) =
  16. mixin `/=`
  17. defineOpAssign(T, `/=`)
  18. defineOpAssigns(Foo)
  19. # bug #1543
  20. import sequtils
  21. (var i = @[""];i).applyIt(it)
  22. # now works:
  23. doAssert i[0] == ""