tstatic.nim 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. discard """
  2. targets: "c cpp js"
  3. """
  4. template main() =
  5. block: # bug #17589
  6. #[
  7. # all those gave some variation of the same bug:
  8. 'intVal' is not accessible using discriminant 'kind' of type 'TFullReg'
  9. 'floatVal' is not accessible using discriminant 'kind' of type 'TFullReg'
  10. ]#
  11. block:
  12. proc f(a: static uint64): uint64 =
  13. a
  14. const x = 3'u64
  15. static: doAssert f(x) == 3'u64
  16. doAssert f(x) == 3'u64
  17. block:
  18. proc f(a: static uint64): uint64 =
  19. a
  20. const x = 3'u64
  21. static: doAssert f(x) == 3'u64
  22. doAssert f(x) == 3'u64
  23. block:
  24. proc foo(x: uint8): uint8 = x
  25. proc f(a: static uint8): auto = foo(a)
  26. const x = 3'u8
  27. static: doAssert f(x) == 3'u8
  28. doAssert f(x) == 3'u8
  29. block:
  30. template foo2(x: float) =
  31. let b = x == 0
  32. proc foo(x: float) = foo2(x)
  33. proc f(a: static float) = foo(a)
  34. const x = 1.0
  35. static: f(x)
  36. block:
  37. proc foo(x: int32) =
  38. let b = x == 0
  39. proc f(a: static int32) = foo(a)
  40. static: f(32767) # was working
  41. static: f(32768) # was failing because >= int16.high (see isInt16Lit)
  42. block: # bug #14585
  43. const foo_m0ninv = 0x1234'u64
  44. proc foo(m0ninv: static uint64) =
  45. let b = $m0ninv
  46. static:
  47. foo(foo_m0ninv)
  48. static: main()
  49. main()