tconverter_with_constraint.nim 319 B

123456789101112131415161718192021
  1. discard """
  2. errormsg: "type mismatch: got <int>"
  3. file: "tconverter_with_constraint.nim"
  4. line: 20
  5. """
  6. type
  7. MyType = distinct int
  8. converter to_mytype(m: int{lit}): MyType =
  9. m.MyType
  10. proc myproc(m: MyType) =
  11. echo m.int, ".MyType"
  12. myproc(1) # call by literal is ok
  13. var x: int = 12
  14. myproc(x) # should fail