@@ -92,7 +92,46 @@ block distinctBase:
9292 doAssert ($ distinctBase (typeof (b2)) == " string" )
9393 doAssert ($ distinctBase (typeof (c2)) == " int" )
9494
95+ block lenTuple:
96+ type
97+ VectorElementType = SomeNumber | bool
98+ Vec [N : static [int ], T: VectorElementType ] = object
99+ arr* : array [N, T]
100+ Vec4 [T: VectorElementType ] = Vec [4 ,T]
101+ Vec4f = Vec4 [float32 ]
102+
103+ MyTupleType = (int ,float ,string )
104+ static : doAssert MyTupleType .lenTuple == 3
105+
106+ type
107+ MyGenericTuple [T] = (T,int ,float )
108+ MyGenericAlias = MyGenericTuple [string ]
109+ static : doAssert MyGenericAlias .lenTuple == 3
110+
111+ type
112+ MyGenericTuple2 [T,U] = (T,U,string )
113+ MyGenericTuple2Alias [T] = MyGenericTuple2 [T,int ]
114+
115+ MyGenericTuple2Alias2 = MyGenericTuple2Alias [float ]
116+ static : doAssert MyGenericTuple2Alias2 .lenTuple == 3
117+
118+ static : doAssert (int , float ).lenTuple == 2
119+ static : doAssert (1 , ).lenTuple == 1
120+ static : doAssert ().lenTuple == 0
121+
122+ let x = (1 ,2 ,)
123+ doAssert x.lenTuple == 2
124+ doAssert ().lenTuple == 0
125+ doAssert (1 ,).lenTuple == 1
126+ doAssert (int ,).lenTuple == 1
127+ doAssert type (x).lenTuple == 2
128+ doAssert type (x).default.lenTuple == 2
129+ type T1 = (int ,float )
130+ type T2 = T1
131+ doAssert T2 .lenTuple == 2
132+
95133block genericParams:
134+
96135 type Foo [T1 , T2 ]= object
97136 doAssert genericParams (Foo [float , string ]) is (float , string )
98137 type Foo1 = Foo [float , int ]
@@ -103,10 +142,6 @@ block genericParams:
103142 doAssert genericParams (Foo2 ).get (1 ) is Foo1
104143 doAssert (int ,).get (0 ) is int
105144 doAssert (int , float ).get (1 ) is float
106- static : doAssert (int , float ).lenTuple == 2
107- static : doAssert (1 , ).lenTuple == 1
108- static : doAssert ().lenTuple == 0
109-
110145
111146# #############################################
112147# bug 13095
0 commit comments