summary refs log blame commit diff stats
path: root/tests/constr/tconstr1.nim
blob: cb6594213421390a46406e7b262e2261300dd87f (plain) (tree)
1
2
3
4
5
6
7
8




                           

                                  
     



                          
                      



                                             

                                                               


                             


                                                             
                              

                                                             

 
discard """
  file: "tconstr1.nim"
  line: 25
  errormsg: "type mismatch"
"""
# Test array, record constructors

type
  TComplexRecord = tuple[
    s: string,
    x, y: int,
    z: float,
    chars: set[Char]]

proc testSem =
  var
    things: array [0..1, TComplexRecord] = [
      (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}),
      (s: "hi", x: 69, y: 45, z: 1.0, chars: {'a', 'b', 'c'})]
  write(stdout, things[0].x)

const
  things: array [0..1, TComplexRecord] = [
    (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}),
    (s: "hi", x: 69, y: 45, z: 1.0)] #ERROR
  otherThings = [  # the same
    (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}),
    (s: "hi", x: 69, y: 45, z: 1.0, chars: {'a'})]