tpush.nim 560 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. discard """
  2. targets: "c js"
  3. """
  4. # test the new pragmas
  5. {.push warnings: off, hints: off.}
  6. proc noWarning() =
  7. var
  8. x: int
  9. echo(x)
  10. {.pop.}
  11. proc WarnMe() =
  12. var
  13. x: int
  14. echo(x)
  15. # bug #11852
  16. proc foo(x: string, y: int, res: int) =
  17. {.push checks: off}
  18. var a: ptr char = unsafeAddr(x[y])
  19. {.pop.}
  20. if x.len > y:
  21. doAssert ord(a[]) == 51
  22. else:
  23. doAssert x.len + 48 == res
  24. foo("", 0, 48)
  25. foo("abc", 40, 51)
  26. # bug #22362
  27. {.push staticBoundChecks: on.}
  28. proc main(): void =
  29. {.pop.}
  30. discard
  31. {.push staticBoundChecks: on.}
  32. main()