t976.nim 505 B

123456789101112131415161718192021222324252627282930313233
  1. import macros
  2. type
  3. int1 = distinct int
  4. int2 = distinct int
  5. int1g = concept x
  6. x is int1
  7. int2g = concept x
  8. x is int2
  9. proc take[T: int1g](value: int1) =
  10. when T is int2:
  11. static: error("killed in take(int1)")
  12. proc take[T: int2g](vale: int2) =
  13. when T is int1:
  14. static: error("killed in take(int2)")
  15. var i1: int1 = 1.int1
  16. var i2: int2 = 2.int2
  17. take[int1](i1)
  18. take[int2](i2)
  19. template reject(e) =
  20. static: assert(not compiles(e))
  21. reject take[string](i2)
  22. reject take[int1](i2)