tgensymregression.nim 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. discard """
  2. output: '''[0.0, 0.0, 0.0]
  3. [0.0, 0.0, 0.0, 0.0]
  4. 5050
  5. 123'''
  6. """
  7. template mathPerComponent(op: untyped): untyped =
  8. proc op*[N,T](v,u: array[N,T]): array[N,T] {.inline.} =
  9. for i in 0 ..< len(result):
  10. result[i] = `*`(v[i], u[i])
  11. mathPerComponent(`***`)
  12. # bug #5285
  13. when true:
  14. if true:
  15. var v1: array[3, float64]
  16. var v2: array[3, float64]
  17. echo repr(v1 *** v2)
  18. proc foo(): void =
  19. var v1: array[4, float64]
  20. var v2: array[4, float64]
  21. echo repr(v1 *** v2)
  22. foo()
  23. # bug #5383
  24. import sequtils
  25. proc zipWithIndex[A](ts: seq[A]): seq[(int, A)] =
  26. toSeq(pairs(ts))
  27. proc main =
  28. discard zipWithIndex(@["foo", "bar"])
  29. discard zipWithIndex(@[1, 2])
  30. discard zipWithIndex(@[true, false])
  31. main()
  32. # bug #5405
  33. proc main2() =
  34. let s = toSeq(1..100).foldL(a + b)
  35. echo s
  36. main2()
  37. # bug #5467
  38. import macros
  39. converter int2string(x: int): string = $x
  40. template wrap(body: typed): untyped =
  41. body
  42. macro makeProc(): typed =
  43. # Make a template tree
  44. result = quote do:
  45. proc someProc* =
  46. wrap do:
  47. let x = 123
  48. # Implicit conversion here
  49. let s: string = x
  50. echo s
  51. makeProc()
  52. someProc()