tconstr1.nim 727 B

1234567891011121314151617181920212223242526272829
  1. discard """
  2. errormsg: "type mismatch"
  3. file: "tconstr1.nim"
  4. line: 25
  5. """
  6. # Test array, record constructors
  7. type
  8. TComplexRecord = tuple[
  9. s: string,
  10. x, y: int,
  11. z: float,
  12. chars: set[char]]
  13. proc testSem =
  14. var
  15. things: array[0..1, TComplexRecord] = [
  16. (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}),
  17. (s: "hi", x: 69, y: 45, z: 1.0, chars: {'a', 'b', 'c'})]
  18. write(stdout, things[0].x)
  19. const
  20. things: array[0..1, TComplexRecord] = [
  21. (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}),
  22. (s: "hi", x: 69, y: 45, z: 1.0)] #ERROR
  23. otherThings = [ # the same
  24. (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}),
  25. (s: "hi", x: 69, y: 45, z: 1.0, chars: {'a'})]