tnested_generic_instantiation2.nim 415 B

12345678910111213141516171819202122232425262728
  1. discard """
  2. action: compile
  3. """
  4. #[
  5. bug #4766
  6. see also: tnested_generic_instantiation.nim
  7. ]#
  8. proc toString*[T](x: T) =
  9. for name, value in fieldPairs(x):
  10. when compiles(toString(value)):
  11. discard
  12. toString(value)
  13. type
  14. Plain = ref object
  15. discard
  16. Wrapped[T] = object
  17. value: T
  18. converter toWrapped[T](value: T): Wrapped[T] =
  19. Wrapped[T](value: value)
  20. let result = Plain()
  21. toString(result)