t18125_2.nim 398 B

123456789101112131415161718192021
  1. discard """
  2. errormsg: "type mismatch: got <(Child, int)> but expected '(Parent, int)'"
  3. line: 17
  4. """
  5. # issue #18125 solved with correct type relation
  6. type
  7. Parent = ref object of RootObj
  8. Child = ref object of Parent
  9. c: char
  10. func foo(c: char): (Parent, int) =
  11. # Works if you use (Parent(Child(c: c)), 0)
  12. let x = (Child(c: c), 0)
  13. x
  14. let x = foo('x')[0]
  15. doAssert Child(x).c == 'x'