tqualifiedtype.nim 957 B

1234567891011121314151617181920212223242526
  1. # issue #19866
  2. # Switch module import order to switch which of last two
  3. # doAsserts fails
  4. import mqualifiedtype1
  5. import mqualifiedtype2
  6. # this isn't officially supported but needed to point out the issue:
  7. template f(moduleName: untyped): int = sizeof(`moduleName`.A)
  8. template g(someType: untyped): int = sizeof(someType)
  9. # These are legitimately true.
  10. doAssert sizeof(mqualifiedtype1.A) != sizeof(mqualifiedtype2.A)
  11. doAssert g(mqualifiedtype1.A) != g(mqualifiedtype2.A)
  12. # Which means that this should not be true, but is in Nim 1.6
  13. doAssert f(`mqualifiedtype1`) != f(`mqualifiedtype2`)
  14. doAssert f(mqualifiedtype1) != f(mqualifiedtype2)
  15. # These should be true, but depending on import order, exactly one
  16. # fails in Nim 1.2, 1.6 and devel.
  17. doAssert f(`mqualifiedtype1`) == g(mqualifiedtype1.A)
  18. doAssert f(`mqualifiedtype2`) == g(mqualifiedtype2.A)
  19. doAssert f(mqualifiedtype1) == g(mqualifiedtype1.A)
  20. doAssert f(mqualifiedtype2) == g(mqualifiedtype2.A)