tgenerics_issues.nim 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875
  1. discard """
  2. output: '''
  3. 4
  4. 3
  5. (weight: 17.0, color: 100)
  6. perm: 22 det: 22
  7. TMatrix[3, 3, system.int]
  8. 3
  9. @[0.9, 0.1]
  10. U[3]
  11. U[(f: 3)]
  12. U[[3]]
  13. b()
  14. @[1, 2]
  15. @[3, 4]
  16. 1
  17. concrete 88
  18. 123
  19. 1
  20. 2
  21. 3
  22. !!Hi!!
  23. G:0,1:0.1
  24. G:0,1:0.1
  25. H:1:0.1
  26. 0
  27. (foo: none(seq[Foo]), s: "")
  28. (foo: some(@[(a: "world", bar: none(Bar))]), s: "hello,")
  29. @[(a: "hey", bar: none(Bar))]
  30. '''
  31. joinable: false
  32. """
  33. import macros, sequtils, sets, sugar, tables, typetraits
  34. block t88:
  35. type
  36. BaseClass[V] = object of RootObj
  37. b: V
  38. proc new[V](t: typedesc[BaseClass], v: V): BaseClass[V] =
  39. BaseClass[V](b: v)
  40. proc baseMethod[V](v: BaseClass[V]): V = v.b
  41. proc overriddenMethod[V](v: BaseClass[V]): V = v.baseMethod
  42. type
  43. ChildClass[V] = object of BaseClass[V]
  44. c: V
  45. proc new[V](t: typedesc[ChildClass], v1, v2: V): ChildClass[V] =
  46. ChildClass[V](b: v1, c: v2)
  47. proc overriddenMethod[V](v: ChildClass[V]): V = v.c
  48. let c = ChildClass[string].new("Base", "Child")
  49. doAssert c.baseMethod == "Base"
  50. doAssert c.overriddenMethod == "Child"
  51. block t4528:
  52. type GenericBase[T] = ref object of RootObj
  53. type GenericSubclass[T] = ref object of GenericBase[T]
  54. proc foo[T](g: GenericBase[T]) = discard
  55. var bar: GenericSubclass[int]
  56. foo(bar)
  57. block t1050_5597:
  58. type ArrayType[T] = distinct T
  59. proc arrayItem(a: ArrayType): auto =
  60. static: echo(name(type(a).T))
  61. result = (type(a).T)(4)
  62. var arr: ArrayType[int]
  63. echo arrayItem(arr)
  64. # bug #5597
  65. template fail() = "what"
  66. proc g[T](x: var T) =
  67. x.fail = 3
  68. type
  69. Obj = object
  70. fail: int
  71. var y: Obj
  72. g y
  73. block t1789:
  74. type
  75. Foo[N: static[int]] = object
  76. proc bindStaticN[N](foo: Foo[N]) =
  77. var ar0: array[3, int]
  78. var ar1: array[N, int]
  79. var ar2: array[1..N, int]
  80. var ar3: array[0..(N+10), float]
  81. echo N
  82. var f: Foo[3]
  83. f.bindStaticN
  84. # case 2
  85. type
  86. ObjectWithStatic[X, Y: static[int], T] = object
  87. bar: array[X * Y, T] # this one works
  88. AliasWithStatic[X, Y: static[int], T] = array[X * Y, T]
  89. var
  90. x: ObjectWithStatic[1, 2, int]
  91. y: AliasWithStatic[2, 3, int]
  92. # case 3
  93. type
  94. Bar[N: static[int], T] = object
  95. bar: array[N, T]
  96. proc `[]`[N, T](f: Bar[N, T], n: range[0..(N - 1)]): T =
  97. doAssert high(n) == N-1
  98. result = f.bar[n]
  99. var b: Bar[3, int]
  100. doAssert b[2] == 0
  101. block t3977:
  102. type Foo[N: static[int]] = object
  103. proc foo[N](x: Foo[N]) =
  104. let n = N
  105. doAssert N == n
  106. var f1: Foo[42]
  107. f1.foo
  108. block t5570:
  109. type
  110. BaseFruit[T] = object of RootObj
  111. color: T
  112. Banana[T] = object of BaseFruit[uint32]
  113. weight: T
  114. macro printTypeName(typ: typed): untyped =
  115. echo "type ", getType(typ).repr
  116. proc setColor[K](self: var BaseFruit[K], c: int) =
  117. printTypeName(self.color)
  118. self.color = uint32(c)
  119. var x: Banana[float64]
  120. x.weight = 17
  121. printTypeName(x.color)
  122. x.setColor(100)
  123. echo x
  124. block t5643:
  125. type
  126. Matrix[M, N: static[int], T: SomeFloat] = object
  127. data: ref array[N * M, T]
  128. Matrix64[M, N: static[int]] = Matrix[M, N, float64]
  129. proc zeros64(M,N: static[int]): Matrix64[M,N] =
  130. new result.data
  131. for i in 0 ..< (M * N):
  132. result.data[i] = 0'f64
  133. proc bar[M,N: static[int], T](a: Matrix[M,N,T], b: Matrix[M,N,T]) =
  134. discard
  135. let a = zeros64(2,2)
  136. bar(a,a)
  137. # https://github.com/nim-lang/Nim/issues/5643
  138. #
  139. # The test case was failing here, because the compiler failed to
  140. # detect the two matrix instantiations as the same type.
  141. #
  142. # The root cause was that the `T` type variable is a different
  143. # type after the first Matrix type has been matched.
  144. #
  145. # Sigmatch was failing to match the second version of `T`, but
  146. # due to some complex interplay between tyOr, tyTypeDesc and
  147. # tyGenericParam this was allowed to went through. The generic
  148. # instantiation of the second matrix was incomplete and the
  149. # generic cache lookup failed, producing two separate types.
  150. block t5683:
  151. type Matrix[M,N: static[int]] = array[M, array[N, float]]
  152. proc det[M,N](a: Matrix[M,N]): int = N*10 + M
  153. proc perm[M,N](a: Matrix[M,N]): int = M*10 + N
  154. const
  155. a = [ [1.0, 2.0]
  156. , [3.0, 4.0]
  157. ]
  158. echo "perm: ", a.perm, " det: ", a.det
  159. # This tests multiple instantiations of a generic
  160. # proc involving static params:
  161. type
  162. Vector64[N: static[int]] = ref array[N, float64]
  163. Array64[N: static[int]] = array[N, float64]
  164. proc vector[N: static[int]](xs: Array64[N]): Vector64[N] =
  165. new result
  166. for i in 0 ..< N:
  167. result[i] = xs[i]
  168. let v1 = vector([1.0, 2.0, 3.0, 4.0, 5.0])
  169. let v2 = vector([1.0, 2.0, 3.0, 4.0, 5.0])
  170. let v3 = vector([1.0, 2.0, 3.0, 4.0])
  171. block t7794:
  172. type
  173. Data[T:SomeNumber, U:SomeFloat] = ref object
  174. x: T
  175. value*: U
  176. var d = Data[int, float64](x:10.int, value:2'f64)
  177. doAssert d.x == 10
  178. doAssert d.value == 2.0
  179. block t8403:
  180. proc sum[T](s: seq[T], R: typedesc): R =
  181. var sum: R = 0
  182. for x in s:
  183. sum += R(x)
  184. return sum
  185. doAssert @[1, 2, 3].sum(float) == 6.0
  186. block t8439:
  187. type
  188. Cardinal = enum
  189. north, east, south, west
  190. proc foo[cardinal: static[Cardinal]](): int = 1
  191. doAssert foo[north]() == 1
  192. block t8694:
  193. when true:
  194. # Error: undeclared identifier: '|'
  195. proc bar[T](t:T): bool =
  196. runnableExamples:
  197. type Foo = int | float
  198. true
  199. doAssert bar(0)
  200. when true:
  201. # ok
  202. proc bar(t:int): bool =
  203. runnableExamples:
  204. type Foo = int | float
  205. true
  206. doAssert bar(0)
  207. when true:
  208. # Error: undeclared identifier: '|'
  209. proc bar(t:typedesc): bool =
  210. runnableExamples:
  211. type Foo = int | float
  212. true
  213. doAssert bar(int)
  214. block t9130:
  215. when true:
  216. # stack overflow
  217. template baz1(iter: untyped): untyped =
  218. runnableExamples:
  219. import sugar
  220. proc fun(a: proc(x:int): int) = discard
  221. baz1(fun(x:int => x))
  222. discard
  223. proc foo1[A](ts: A) =
  224. baz1(ts)
  225. when true:
  226. # ok
  227. template baz2(iter: untyped): untyped =
  228. runnableExamples:
  229. import sugar
  230. proc fun(a: proc(x:int): int) = discard
  231. baz2(fun(x:int => x))
  232. discard
  233. proc foo2(ts: int) =
  234. baz2(ts)
  235. when true:
  236. # stack overflow
  237. template baz3(iter: untyped): untyped =
  238. runnableExamples:
  239. baz3(fun(x:int => x))
  240. discard
  241. proc foo3[A](ts: A) =
  242. baz3(ts)
  243. block t1056:
  244. type
  245. TMatrix[N,M: static[int], T] = object
  246. data: array[0..N*M-1, T]
  247. TMat2[T] = TMatrix[2,2,T]
  248. proc echoMatrix(a: TMatrix) =
  249. echo a.type.name
  250. echo TMatrix.N
  251. proc echoMat2(a: TMat2) =
  252. echo TMat2.M
  253. var m = TMatrix[3,3,int](data: [1,2,3,4,5,6,7,8,9])
  254. echoMatrix m
  255. block t4884:
  256. type
  257. Vec[N: static[int], T] = object
  258. arr*: array[N, T]
  259. Mat[N,M: static[int], T] = object
  260. arr: array[N, Vec[M,T]]
  261. var m : Mat[3,3,float]
  262. var strMat : Mat[m.N, m.M, string]
  263. var lenMat : Mat[m.N, m.M, int]
  264. block t2221:
  265. var tblo: TableRef[string, int]
  266. doAssert tblo == nil
  267. block t2304:
  268. type TV2[T:SomeNumber] = array[0..1, T]
  269. proc newV2T[T](x, y: T=0): TV2[T] = [x, y]
  270. let x = newV2T[float](0.9, 0.1)
  271. echo(@x)
  272. block t2752:
  273. proc myFilter[T](it: (iterator(): T), f: (proc(anything: T):bool)): (iterator(): T) =
  274. iterator aNameWhichWillConflict(): T {.closure.}=
  275. for x in it():
  276. if f(x):
  277. yield x
  278. result = aNameWhichWillConflict
  279. iterator testIt():int {.closure.}=
  280. yield -1
  281. yield 2
  282. #let unusedVariable = myFilter(testIt, (x: int) => x > 0)
  283. proc onlyPos(it: (iterator(): int)): (iterator(): int)=
  284. iterator aNameWhichWillConflict(): int {.closure.}=
  285. var filtered = onlyPos(myFilter(it, (x:int) => x > 0))
  286. for x in filtered():
  287. yield x
  288. result = aNameWhichWillConflict
  289. let x = onlyPos(testIt)
  290. block t5106:
  291. block:
  292. type T = distinct int
  293. proc `+`(a, b: T): T =
  294. T(int(a) + int(b))
  295. type U[F: static[T]] = distinct int
  296. proc `+`[P1, P2: static[T]](a: U[P1], b: U[P2]): U[P1 + P2] =
  297. U[P1 + P2](int(a) + int(b))
  298. var a = U[T(1)](1)
  299. var b = U[T(2)](2)
  300. var c = a + b
  301. echo c.type.name
  302. block:
  303. type T = object
  304. f: int
  305. proc `+`(a, b: T): T =
  306. T(f: a.f + b.f)
  307. type U[F: static[T]] = distinct int
  308. proc `+`[P1, P2: static[T]](a: U[P1], b: U[P2]): U[P1 + P2] =
  309. U[P1 + P2](int(a) + int(b))
  310. var a = U[T(f: 1)](1)
  311. var b = U[T(f: 2)](2)
  312. var c = a + b
  313. echo c.type.name
  314. block:
  315. type T = distinct array[0..0, int]
  316. proc `+`(a, b: T): T =
  317. T([array[0..0, int](a)[0] + array[0..0, int](b)[0]])
  318. type U[F: static[T]] = distinct int
  319. proc `+`[P1, P2: static[T]](a: U[P1], b: U[P2]): U[P1 + P2] =
  320. U[P1 + P2](int(a) + int(b))
  321. var a = U[T([1])](1)
  322. var b = U[T([2])](2)
  323. var c = a + b
  324. echo c.type.name
  325. block t3055:
  326. proc b(t: int | string)
  327. proc a(t: int) = b(t)
  328. proc b(t: int | string) = echo "b()"
  329. a(1)
  330. # test recursive generics still work:
  331. proc fac[T](x: T): T =
  332. if x == 0: return 1
  333. else: return fac(x-1)*x
  334. doAssert fac(6) == 720
  335. doAssert fac(5.0) == 120.0
  336. # test recursive generic with forwarding:
  337. proc fac2[T](x: T): T
  338. doAssert fac2(6) == 720
  339. doAssert fac2(5.0) == 120.0
  340. proc fac2[T](x: T): T =
  341. if x == 0: return 1
  342. else: return fac2(x-1)*x
  343. block t1187:
  344. type
  345. TEventArgs = object
  346. skip: bool
  347. TEventHandler[T] = proc (e: var TEventArgs, data: T) {.closure.}
  348. TEvent[T] = object
  349. #handlers: seq[TEventHandler[T]] # Does not work
  350. handlers: seq[proc (e: var TEventArgs, d: T) {.closure.}] # works
  351. TData = object
  352. x: int
  353. TSomething = object
  354. s: TEvent[TData]
  355. proc init[T](e: var TEvent[T]) =
  356. e.handlers.newSeq(0)
  357. #proc add*[T](e: var TEvent[T], h: proc (e: var TEventArgs, data: T) {.closure.}) =
  358. # this line works
  359. proc add[T](e: var TEvent[T], h: TEventHandler[T]) =
  360. # this line does not work
  361. e.handlers.add(h)
  362. proc main () =
  363. var something: TSomething
  364. something.s.init()
  365. var fromOutside = 4711
  366. something.s.add() do (e: var TEventArgs, data: TData):
  367. var x = data.x
  368. x = fromOutside
  369. main()
  370. block t1919:
  371. type
  372. Base[M] = object of RootObj
  373. a : M
  374. Sub1[M] = object of Base[M]
  375. b : int
  376. Sub2[M] = object of Sub1[M]
  377. c : int
  378. var x: Sub2[float]
  379. doAssert x.a == 0.0
  380. block t5756:
  381. type
  382. Vec[N : static[int]] = object
  383. x: int
  384. arr: array[N, int32]
  385. Mat[M,N: static[int]] = object
  386. x: int
  387. arr: array[M, Vec[N]]
  388. proc vec2(x,y:int32) : Vec[2] =
  389. result.arr = [x,y]
  390. result.x = 10
  391. proc mat2(a,b: Vec[2]): Mat[2,2] =
  392. result.arr = [a,b]
  393. result.x = 20
  394. const M = mat2(vec2(1, 2), vec2(3, 4))
  395. let m1 = M
  396. echo @(m1.arr[0].arr)
  397. echo @(m1.arr[1].arr)
  398. proc foo =
  399. let m2 = M
  400. echo m1.arr[0].arr[0]
  401. foo()
  402. block t7854:
  403. type
  404. Stream = ref StreamObj
  405. StreamObj = object of RootObj
  406. InhStream = ref InhStreamObj
  407. InhStreamObj = object of Stream
  408. f: string
  409. proc newInhStream(f: string): InhStream =
  410. new(result)
  411. result.f = f
  412. var val: int
  413. let str = newInhStream("input_file.json")
  414. block:
  415. # works:
  416. proc load[T](data: var T, s: Stream) =
  417. discard
  418. load(val, str)
  419. block:
  420. # works
  421. proc load[T](s: Stream, data: T) =
  422. discard
  423. load(str, val)
  424. block:
  425. # broken
  426. proc load[T](s: Stream, data: var T) =
  427. discard
  428. load(str, val)
  429. block t5864:
  430. proc defaultStatic(s: openArray, N: static[int] = 1): int = N
  431. proc defaultGeneric[T](a: T = 2): int = a
  432. let a = [1, 2, 3, 4].defaultStatic()
  433. let b = defaultGeneric()
  434. doAssert a == 1
  435. doAssert b == 2
  436. block t3498:
  437. template defaultOf[T](t: T): untyped = (var d: T; d)
  438. doAssert defaultOf(1) == 0
  439. # assignment using template
  440. template tassign[T](x: var seq[T]) =
  441. x = @[1, 2, 3]
  442. var y: seq[int]
  443. tassign(y) #<- x is expected = @[1, 2, 3]
  444. tassign(y)
  445. doAssert y[0] == 1
  446. doAssert y[1] == 2
  447. doAssert y[2] == 3
  448. block t3499:
  449. proc foo[T](x: proc(): T) =
  450. echo "generic ", x()
  451. proc foo(x: proc(): int) =
  452. echo "concrete ", x()
  453. # note the following 'proc' is not .closure!
  454. foo(proc (): auto {.nimcall.} = 88)
  455. # bug #3499 last snippet fixed
  456. # bug 705 last snippet fixed
  457. block t797:
  458. proc foo[T](s:T):string = $s
  459. type IntStringProc = proc(x: int): string
  460. var f1 = IntStringProc(foo)
  461. var f2: proc(x: int): string = foo
  462. var f3: IntStringProc = foo
  463. echo f1(1), f2(2), f3(3)
  464. for x in map([1,2,3], foo): echo x
  465. block t4658:
  466. var x = 123
  467. proc twice[T](f: T -> T): T -> T = (x: T) => f(f(x))
  468. proc quote(s: string): string = "!" & s & "!"
  469. echo twice(quote)("Hi")
  470. block t4589:
  471. type SimpleTable[TKey, TVal] = TableRef[TKey, TVal]
  472. template newSimpleTable(TKey, TVal: typedesc): SimpleTable[TKey, TVal] = newTable[TKey, TVal]()
  473. var fontCache : SimpleTable[string, SimpleTable[int32, int]]
  474. fontCache = newSimpleTable(string, SimpleTable[int32, int])
  475. block t4600:
  476. template foo(x: untyped): untyped = echo 1
  477. template foo(x,y: untyped): untyped = echo 2
  478. proc bar1[T](x: T) = foo(x)
  479. proc bar2(x: float) = foo(x,x)
  480. proc bar3[T](x: T) = foo(x,x)
  481. block t4672:
  482. type
  483. EnumContainer[T: enum] = object
  484. v: T
  485. SomeEnum {.pure.} = enum
  486. A,B,C
  487. proc value[T: enum](this: EnumContainer[T]): T =
  488. this.v
  489. var enumContainer: EnumContainer[SomeEnum]
  490. discard enumContainer.value()
  491. block t4863:
  492. type
  493. G[i,j: static[int]] = object
  494. v:float
  495. H[j: static[int]] = G[0,j]
  496. proc p[i,j: static[int]](x:G[i,j]) = echo "G:", i, ",", j, ":", x.v
  497. proc q[j: static[int]](x:H[j]) = echo "H:", j, ":", x.v
  498. var
  499. g0 = G[0,1](v: 0.1)
  500. h0:H[1] = g0
  501. p(g0)
  502. p(h0)
  503. q(h0)
  504. block t1684:
  505. type
  506. BaseType {.inheritable pure.} = object
  507. idx: int
  508. DerivedType {.final pure.} = object of BaseType
  509. proc index[Toohoo: BaseType](h: Toohoo): int {.inline.} = h.idx
  510. proc newDerived(idx: int): DerivedType {.inline.} = DerivedType(idx: idx)
  511. let d = newDerived(2)
  512. doAssert(d.index == 2)
  513. block t5632:
  514. type Option[T] = object
  515. proc point[A](v: A, t: typedesc[Option[A]]): Option[A] =
  516. discard
  517. discard point(1, Option)
  518. block t7247:
  519. type n8 = range[0'i8..127'i8]
  520. var tab = initHashSet[n8]()
  521. doAssert tab.contains(8) == false
  522. block t3717:
  523. type
  524. Foo[T] = object
  525. a: T
  526. Foo1[T] = Foo[T] | int
  527. proc foo[T](s: Foo1[Foo[T]]): T =
  528. 5
  529. var f: Foo[Foo[int]]
  530. discard foo(f)
  531. block: # issue #9458
  532. type
  533. Option[T] = object
  534. val: T
  535. has: bool
  536. Bar = object
  537. proc none(T: typedesc): Option[T] =
  538. discard
  539. proc foo[T](self: T; x: Option[Bar] = Bar.none) =
  540. discard
  541. foo(1)
  542. # bug #8426
  543. type
  544. MyBool[T: uint] = range[T(0)..T(1)] # Works
  545. var x: MyBool[uint]
  546. echo x
  547. # x = 2 # correctly prevented
  548. type
  549. MyBool2 = range[uint(0)..uint(1)] # Error ordinal or float type expected
  550. # bug #10396
  551. import options, strutils
  552. type
  553. Foo {.acyclic.} = object
  554. a: string
  555. bar: Option[Bar]
  556. Bar {.acyclic.} = object
  557. foo: Option[seq[Foo]] # if this was just Option[Foo], everything works fine
  558. s: string
  559. proc getBar(x: string): Bar
  560. proc intoFoos(ss: seq[string]): seq[Foo] =
  561. result = @[]
  562. for s in ss:
  563. let spl = s.split(',')
  564. if spl.len > 1:
  565. result.add Foo(a: spl[0],
  566. bar: some(getBar(spl[1])))
  567. else:
  568. result.add Foo(a: s,
  569. bar: none[Bar]())
  570. proc getBar(x: string): Bar =
  571. let spl = x.split(' ')
  572. result =
  573. if spl.len > 1:
  574. Bar(foo: some(spl[1..high(spl)].intoFoos),
  575. s: spl[0])
  576. else:
  577. Bar(foo: none[seq[Foo]](),
  578. s: "")
  579. proc fakeReadLine(): string = "hey"
  580. echo getBar(fakeReadLine()) # causes error
  581. echo getBar("hello, world") # causes error
  582. discard $getBar(fakeReadLine()) # causes error
  583. discard $getBar("hello, world") # causes error
  584. discard getBar(fakeReadLine()) # no error
  585. discard getBar("hello, world") # no error
  586. echo intoFoos(fakeReadLine().split(' ')) # no error, works as expected
  587. # bug #14990
  588. type
  589. Tile3 = Tile2
  590. Tile2 = Tile
  591. Tile[n] = object
  592. a: n
  593. var a: Tile3[int]
  594. block: # Ensure no segfault from constraint
  595. type
  596. Regex[A: SomeOrdinal] = ref object
  597. val: Regex[A]
  598. MyConstraint = (seq or enum or set)
  599. MyOtherType[A: MyConstraint] = ref object
  600. val: MyOtherType[A]
  601. var
  602. a = Regex[int]()
  603. b = Regex[bool]()
  604. c = MyOtherType[seq[int]]()