To put it another way, borrowing a geneaological term:

when initializing a seq with a set of inheritable types, the resulting type 
will be that of the most recent common ancestor of those types.
    
    
    type
      Fish{.inheritable.} = ref object
      RayFinnedFish = ref object of Fish
      Tuna = ref object of RayFinnedFish
      LobeFinnedFish = ref object of Fish
      Coelacanth = ref object of LobeFinnedFish
      Tetrapod = ref object of LobeFinnedFish
      Human = ref object of TetraPod
      Chicken = ref object of TetraPod
    
    let adam = Human()
    let eve = Human()
    let fifi = Chicken()
    let jack = Tuna()
    
    assert typeof(@[adam,eve]) is seq[Human]
    assert typeof(@[adam,fifi]) is seq[Tetrapod]
    assert  typeof(@[eve,adam,jack]) is seq[Fish]
    
    
    Run

Reply via email to