tnocompiletimefunc.nim 267 B

123456789101112131415
  1. discard """
  2. errormsg: "request to generate code for .compileTime proc: foo"
  3. """
  4. # ensure compileTime funcs can't be called from runtime
  5. func foo(a: int): int {.compileTime.} =
  6. a * a
  7. proc doAThing(): int =
  8. for i in 0..2:
  9. result += foo(i)
  10. echo doAThing()