twrongdefaultvalue.nim 808 B

1234567891011121314151617181920212223242526
  1. discard """
  2. cmd: "nim check $file"
  3. action: reject
  4. nimout: '''
  5. twrongdefaultvalue.nim(20, 12) template/generic instantiation of `doit` from here
  6. twrongdefaultvalue.nim(17, 37) Error: type mismatch: got <proc (p: int): Item[initItem.T]> but expected 'Item[system.string]'
  7. twrongdefaultvalue.nim(25, 3) template/generic instantiation of `foo` from here
  8. twrongdefaultvalue.nim(23, 33) Error: type mismatch: got <string> but expected 'int'
  9. '''
  10. """
  11. block: # issue #21258
  12. type Item[T] = object
  13. pos: int
  14. proc initItem[T](p:int=10000) : Item[T] =
  15. result = Item[T](p)
  16. proc doit[T](x:Item[T], s:Item[T]=initItem) : string =
  17. return $x.pos
  18. let x = Item[string](pos:100)
  19. echo doit(x)
  20. block: # issue #21258, reduced case
  21. proc foo[T](x: seq[T], y: T = "foo") =
  22. discard
  23. foo @[1, 2, 3]