trangeincompatible.nim 988 B

123456789101112131415161718192021222324252627282930313233
  1. block: # issue #20142
  2. let
  3. s1: set['a' .. 'g'] = {'a', 'e'}
  4. s2: set['a' .. 'g'] = {'b', 'c', 'd', 'f'} # this works fine
  5. s3 = {'b', 'c', 'd', 'f'}
  6. doAssert s1 != s2
  7. doAssert s1 == {range['a'..'g'] 'a', 'e'}
  8. doAssert s2 == {range['a'..'g'] 'b', 'c', 'd', 'f'}
  9. # literal conversion:
  10. doAssert s1 == {'a', 'e'}
  11. doAssert s2 == {'b', 'c', 'd', 'f'}
  12. doAssert s3 == {'b', 'c', 'd', 'f'}
  13. doAssert not compiles(s1 == s3)
  14. doAssert not compiles(s2 == s3)
  15. # can't convert literal 'z', overload match fails
  16. doAssert not compiles(s1 == {'a', 'z'})
  17. block: # issue #18396
  18. var s1: set[char] = {'a', 'b'}
  19. var s2: set['a'..'z'] = {'a', 'b'}
  20. doAssert s1 == {'a', 'b'}
  21. doAssert s2 == {range['a'..'z'] 'a', 'b'}
  22. doAssert s2 == {'a', 'b'}
  23. doAssert not compiles(s1 == s2)
  24. block: # issue #16270
  25. var s1: set[char] = {'a', 'b'}
  26. var s2: set['a'..'z'] = {'a', 'c'}
  27. doAssert not (compiles do: s2 = s2 + s1)
  28. s2 = s2 + {'a', 'b'}
  29. doAssert s2 == {'a', 'b', 'c'}