summary refs log tree commit diff stats
path: root/tests/gc
Commit message (Expand)AuthorAgeFilesLines
* new implementations for --gc:orc (#14121)Andreas Rumpf2020-04-271-1/+2
* faster CIs (#13803)Miran2020-03-303-10/+10
* save another 33s of CI for tests/gc/gcleak.nimTimothee Cour2020-02-271-1/+8
* CI tests run faster: save 120s in azure machines, 335s on local OSXTimothee Cour2020-02-271-1/+13
* revert changes to tests/gc/gcleak2.nimTimothee Cour2020-02-271-72/+5
* make CI tests faster + more preciseTimothee Cour2020-02-271-5/+72
* TlSF Alloctor: use less memory for --gc:arc (#13280)Andreas Rumpf2020-01-281-0/+2
* fixes #12899 (#12921)Andreas Rumpf2019-12-181-2/+2
* ARC: cycle detector (#12823)Andreas Rumpf2019-12-172-17/+29
* fixes a flaky test for the realtime GCAraq2019-11-281-3/+0
* ARC: ported the GC tests over to --gc:arcAraq2019-11-266-15/+31
* thavlak.nim: more idiomatic codeAraq2019-11-211-45/+45
* more thavlak.nim improvementsAraq2019-11-211-4/+4
* more thavlak.nim improvementsAraq2019-11-211-78/+51
* thavlak.nim test: improved the code styleAraq2019-11-211-28/+21
* remove deprecated procs (#12535)Andreas Rumpf2019-11-051-2/+2
* fix several typos in documentation and comments (#12553)Nindaleth2019-10-301-1/+1
* gcbench: better memory usage reportAndreas Rumpf2019-09-031-2/+2
* Remove ENDB (#12095)Clyybber2019-08-311-2/+0
* thavlak: code style changesAndreas Rumpf2019-08-211-18/+20
* travis: cleanup & add 32-bit Linux testing (#11337)alaviss2019-05-301-0/+1
* make tests green againAraq2019-05-271-8/+3
* ported havlak and gcbench benchmarks to work with --gc:regionsAndreas Rumpf2019-01-192-41/+54
* GC tests: make them take less time to save CI cyclesAndreas Rumpf2019-01-192-7/+5
* make thavlak and tmarkerproc_regression tests take fewer iterations in order ...Araq2018-10-171-5/+5
* make more tests green; system.repr does not produce 'nil' for strings and seq...Araq2018-08-221-1/+1
* make more things compile without isNilAraq2018-08-221-2/+1
* make growobjcrash complete earlierAraq2018-08-051-1/+1
* fixes #7833; still to-do: fix setLenAraq2018-07-301-2/+2
* Testament should run tests with no action (#8232)genotrance2018-07-081-1/+0
* make tests green againAndreas Rumpf2018-07-051-3/+3
* turn destructors into finalizersAndreas Rumpf2018-07-051-3/+3
* Fix gc tests for BoehmGC (#7094)Sergey Avseyev2018-01-183-6/+3
* hardened gctestAraq2018-01-151-3/+3
* GC improvements; distinguish between thread local and globals in the marking ...Araq2018-01-142-21/+36
* fixArne Döring2017-07-241-1/+1
* Add ``tearDownForeignThreadGc`` function (#5369)Anatoly Galiulin2017-02-131-0/+88
* fixes #3184Andreas Rumpf2016-05-221-0/+457
* fixes #3793Andreas Rumpf2016-05-161-0/+37
* makes tests greenAndreas Rumpf2016-01-151-1/+1
* Added a test to check how gc works in emscripten.Andrey Sobolev2015-09-231-0/+59
* tests: Trim .nim files trailing whitespaceAdam Strzelecki2015-09-046-173/+173
* Don't access GCed field in finalizer. Fixes #2305Yuriy Glukhov2015-08-241-8/+7
* renamed writeln to writeLine in testspatrick dw2015-06-191-14/+14
* increase limit for 64bit systemsAraq2015-02-101-1/+1
* fixes #2070Araq2015-02-101-0/+29
* cleaned up GC tests; fixes object variant re-assign bugAraq2015-02-101-1/+3
* fixes #1796Araq2015-01-053-3/+25
* make tests greenAraq2014-08-311-1/+1
* further adaptationsAraq2014-08-291-1/+1
.com> 2022-10-04 18:45:10 +0800 committer GitHub <noreply@github.com> 2022-10-04 12:45:10 +0200 add default field support for object in ARC/ORC (#20480)' href='/ahoang/Nim/commit/tests/objects/tobject_default_value.nim?h=devel&id=f89ba2c951232fe7f82d211fe43f774e68563a73'>f89ba2c95 ^
55373e65b ^
f89ba2c95 ^









079363bfc ^
f89ba2c95 ^







079363bfc ^
f89ba2c95 ^












079363bfc ^
f89ba2c95 ^




f89ba2c95 ^











































079363bfc ^
f89ba2c95 ^























affd3f785 ^
f89ba2c95 ^















079363bfc ^
f89ba2c95 ^























079363bfc ^
f89ba2c95 ^


141abb7b7 ^
f89ba2c95 ^
079363bfc ^
f89ba2c95 ^




141abb7b7 ^




f89ba2c95 ^














141abb7b7 ^


f89ba2c95 ^
141abb7b7 ^

f89ba2c95 ^
39f925b95 ^





























f89ba2c95 ^
c4e5dab41 ^


















165d523ed ^














c4e5dab41 ^
bbb6d2c69 ^


































031982432 ^































ebdff1c7d ^






















9c40dd240 ^









































































f524d60fa ^













bbb6d2c69 ^
affd3f785 ^













96513b250 ^


























e96fad1ee ^



affd3f785 ^
a33e2b76a ^













e96fad1ee ^







ac0179ced ^




f89ba2c95 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780




                                                                                                              
                                  






















                                



                          






















































































                                                            

                                       
 
                      

                          









                                       
                                       

                          





















                                  
                           




                                                        


                                            












                                                      
                    








                           
                                    














                                   
                            




                               





                               




                                    






                                   




                                   
          

















                                          











                                                                          
                
                                                         









                                       
                                







                               
                                  












                                    
                                




                          











































                                      
                                  























                                     
                            















                                 
                                    























                                                                 
                              


                                           
 
          
                            




                                               




                                               














                                         


                              
 

                                                
 





























                           
 


















                                                   














                                        
 


































                                                           































                                      






















                                            









































































                                                                  













                                                  
 













                          


























                                                  



                                          
 













                                          







                            




                                   

              
discard """
  matrix: "-d:nimPreviewRangeDefault --mm:refc; -d:nimPreviewRangeDefault --warningAsError:ProveInit --mm:orc"
  targets: "c cpp js"
"""

import std/[times, macros, tables]

type
  Guess = object
    poi: DateTime

  GuessDistinct = distinct Guess

block:
  var x: Guess
  discard Guess()

  var y: GuessDistinct

  discard y

  discard GuessDistinct(x)


import mobject_default_value

block:
  let x = Default()
  doAssert x.se == 0'i32

block:
  let x = default(Default)
  doAssert x.se == 0'i32
# echo Default(poi: 12)
# echo Default(poi: 17)

# echo NonDefault(poi: 77)

block:
  var x: Default
  doAssert x.se == 0'i32

type
  ObjectBase = object of RootObj
    value = 12

  ObjectBaseDistinct = distinct ObjectBase

  DinstinctInObject = object
    data: ObjectBaseDistinct

  Object = object of ObjectBase
    time: float = 1.2
    date: int
    scale: range[1..10]

  Object2 = object
    name: Object

  Object3 = object
    obj: Object2

  ObjectTuple = tuple
    base: ObjectBase
    typ: int
    obj: Object

  TupleInObject = object
    size = 777
    data: ObjectTuple

  Ref = ref object of ObjectBase

  RefInt = ref object of Ref
    data = 73

  Ref2 = ref object of ObjectBase

  RefInt2 = ref object of Ref
    data = 73

var t {.threadvar.}: Default
# var m1, m2 {.threadvar.}: Default

block:
  doAssert t.se == 0'i32

block: # ARC/ORC cannot bind destructors twice, so it cannot
      # be moved into main
  block:
    var x: Ref
    new(x)
    doAssert x.value == 12, "Ref.value = " & $x.value

    var y: RefInt
    new(y)
    doAssert y.value == 12
    doAssert y.data == 73

  block:
    var x: Ref2
    new(x, proc (x: Ref2) {.nimcall.} = discard "call Ref")
    doAssert x.value == 12, "Ref.value = " & $x.value

    proc call(x: RefInt2) =
      discard "call RefInt"

    var y: RefInt2
    new(y, call)
    doAssert y.value == 12
    doAssert y.data == 73

template main {.dirty.} =
  block: # bug #16744
    type
      R = range[1..10]
      Obj = object
        r: R

    var
      rVal: R = default(R) # Works fine
      objVal = default(Obj)

    doAssert rVal == 1
    doAssert objVal.r == 1

  block: # bug #16744
    type
      R = range[1..10]
      Obj = object
        r: R

    var
      rVal: R = default(R) # Works fine
      objVal = Obj()

    doAssert rVal == 1 # it should be 1
    doAssert objVal.r == 1

  block: # bug #3608
    type
      abc = ref object
        w: range[2..100]

    proc createABC(): abc =
      new(result)
      result.w = 20

    doAssert createABC().w == 20

  block:
    var x = new ObjectBase
    doAssert x.value == 12

    proc hello(): ref ObjectBase =
      new result

    let z = hello()
    doAssert z.value == 12

  block:
    var base = ObjectBase()
    var x: ObjectBaseDistinct = ObjectBaseDistinct(base)
    doAssert ObjectBase(x).value == 12
    let y = ObjectBaseDistinct(default(ObjectBase))
    doAssert ObjectBase(y).value == 12

    let m = ObjectBaseDistinct(ObjectBase())
    doAssert ObjectBase(m).value == 12

    proc hello(): ObjectBaseDistinct =
      result = ObjectBaseDistinct(default(ObjectBase))

    let z = hello()
    doAssert ObjectBase(z).value == 12

  block:
    var x: DinstinctInObject
    x.data = ObjectBaseDistinct(default(ObjectBase))

    doAssert ObjectBase(x.data).value == 12

  block:
    var x = Object()
    doAssert x.value == 12
    doAssert x.time == 1.2
    doAssert x.scale == 1

    let y = default(Object)
    doAssert y.value == 12
    doAssert y.time == 1.2
    doAssert y.scale == 1

    var x1, x2, x3 = default(Object)
    doAssert x1.value == 12
    doAssert x1.time == 1.2
    doAssert x1.scale == 1
    doAssert x2.value == 12
    doAssert x2.time == 1.2
    doAssert x2.scale == 1
    doAssert x3.value == 12
    doAssert x3.time == 1.2
    doAssert x3.scale == 1

  block:
    var x = new Object
    doAssert x[] == default(Object)

  block:
    var x = default(Object2)
    doAssert x.name.value == 12
    doAssert x.name.time == 1.2
    doAssert x.name.scale == 1

  block:
    let x = Object2()
    doAssert x.name.value == 12
    doAssert x.name.time == 1.2
    doAssert x.name.scale == 1

  block:
    var x: ref Object2
    new x
    doAssert x[] == default(Object2)

  block:
    var x = default(Object3)
    doAssert x.obj.name.value == 12
    doAssert x.obj.name.time == 1.2
    doAssert x.obj.name.scale == 1

  block:
    var x = Object3()
    doAssert x.obj.name.value == 12
    doAssert x.obj.name.time == 1.2
    doAssert x.obj.name.scale == 1

  when nimvm:
    # todo
    discard "fixme"
  else:
    when defined(gcArc) or defined(gcOrc):
      block: #seq
        var x = newSeq[Object](10)
        let y = x[0]
        doAssert y.value == 12
        doAssert y.time == 1.2
        doAssert y.scale == 1

      block:
        var x: seq[Object]
        setLen(x, 5)
        let y = x[^1]
        doAssert y.value == 12
        doAssert y.time == 1.2
        doAssert y.scale == 1

      block:
        var my = @[1, 2, 3, 4, 5]
        my.setLen(0)
        my.setLen(5)
        doAssert my == @[0, 0, 0, 0, 0]

      block:
        var my = "hello"
        my.setLen(0)
        my.setLen(5)
        doAssert $(@my) == """@['\x00', '\x00', '\x00', '\x00', '\x00']"""

  block: # array
    var x: array[10, Object] = default(array[10, Object])
    let y = x[0]
    doAssert y.value == 12
    doAssert y.time == 1.2
    doAssert y.scale == 1

  block: # array
    var x {.noinit.}: array[10, Object]
    discard x

  block: # tuple
    var x = default(ObjectTuple)
    doAssert x.base.value == 12
    doAssert x.typ == 0
    doAssert x.obj.time == 1.2
    doAssert x.obj.date == 0
    doAssert x.obj.scale == 1
    doAssert x.obj.value == 12

  block: # tuple in object
    var x = default(TupleInObject)
    doAssert x.data.base.value == 12
    doAssert x.data.typ == 0
    doAssert x.data.obj.time == 1.2
    doAssert x.data.obj.date == 0
    doAssert x.data.obj.scale == 1
    doAssert x.data.obj.value == 12
    doAssert x.size == 777

  type
    ObjectArray = object
      data: array[10, Object]

  block:
    var x = default(ObjectArray)
    let y = x.data[0]
    doAssert y.value == 12
    doAssert y.time == 1.2
    doAssert y.scale == 1

  block:
    var x: PrellDeque[int]
    doAssert x.pendingTasks == 0

  type
    Color = enum
      Red, Blue, Yellow

    ObjectVarint = object
      case kind: Color
      of Red:
        data: int = 10
      of Blue:
        fill = "123"
      of Yellow:
        time = 1.8'f32

    ObjectVarint1 = object
      case kind: Color = Blue
      of Red:
        data1: int = 10
      of Blue:
        fill2 = "123"
        cry: float
      of Yellow:
        time3 = 1.8'f32
        him: int

  block:
    var x = ObjectVarint(kind: Red)
    doAssert x.kind == Red
    doAssert x.data == 10

  block:
    var x = ObjectVarint(kind: Blue)
    doAssert x.kind == Blue
    doAssert x.fill == "123"

  block:
    var x = ObjectVarint(kind: Yellow)
    doAssert x.kind == Yellow
    doAssert typeof(x.time) is float32

  block:
    var x = default(ObjectVarint1)
    doAssert x.kind == Blue
    doAssert x.fill2 == "123"
    x.cry = 326

  type
    ObjectVarint2 = object
      case kind: Color
      of Red:
        data: int = 10
      of Blue:
        fill = "123"
      of Yellow:
        time = 1.8'f32

  block:
    var x = ObjectVarint2(kind: Blue)
    doAssert x.fill == "123"

  block:
    type
      Color = enum
        Red, Blue, Yellow
  
    type
      ObjectVarint3 = object
        case kind: Color = Blue
        of Red:
          data1: int = 10
        of Blue:
          case name: Color = Blue
          of Blue:
            go = 12
          else:
            temp = 66
          fill2 = "123"
          cry: float
        of Yellow:
          time3 = 1.8'f32
          him: int

    block:
      var x = default(ObjectVarint3)
      doAssert x.kind == Blue
      doAssert x.name == Blue
      doAssert x.go == 12

    block:
      var x = ObjectVarint3(kind: Blue, name: Red, temp: 99)
      doAssert x.kind == Blue
      doAssert x.name == Red
      doAssert x.temp == 99

  block:
    type
      Default = tuple
        id: int = 1
        obj: ObjectBase
        name: string

      Class = object
        def: Default

      Member = object
        def: Default = (id: 777, obj: ObjectBase(), name: "fine")

    block:
      var x = default(Default)
      doAssert x.id == 1
      doAssert x.obj == default(ObjectBase)
      doAssert x.name == ""

    block:
      var x = default(Class)
      doAssert x.def == default(Default)
      doAssert x.def.id == 1
      doAssert x.def.obj == default(ObjectBase)
      doAssert x.def.name == ""

    block:
      var x = default(Member)
      doAssert x.def.id == 777
      doAssert x.def.obj == default(ObjectBase)
      doAssert x.def.name == "fine"

  block:
    var x {.noinit.} = 12
    doAssert x == 12

    type
      Pure = object
        id: int = 12

    var y {.noinit.}: Pure
    doAssert y.id == 0

    var z {.noinit.}: Pure = Pure(id: 77)
    doAssert z.id == 77

  block: # bug #20681
    type A = object
      d: DateTime = DateTime()

    let x = default(A)
    doAssert $x == "(d: Uninitialized DateTime)"

  block: # bug #20715
    block:
      type
        Foo = enum
          A
          B

        Bar = object
          case foo: Foo
          of A:
            t: range[-1..2]
          else: discard

      var d = default(Bar)
      doAssert d.t == -1

    block:
      type
        Foo = enum
          A
          B

        Bar = object
          case foo: Foo
          of A:
            t: range[0..2]
          else: discard

      var d = default(Bar)
      doAssert d.t == 0

    block: # bug #20740
      block:
        proc foo(x: static DateTime = Datetime()) =
          discard

        foo()

      block:
        macro foo(x: static DateTime) =
          discard x

        macro foo2: untyped =
          var x = DateTime()

          result = quote do:
            foo(`x`)

        foo2()


  block: # issue #20699
    type
      Either[A,B] = object
        case kind:bool
        of false:
          b: B
        of true:
            a: A
      O = object of RootRef

    proc oToEither(o:O):Either[O,void] =
      Either[O,void](kind:true,a: o)

    discard oToEither(O())

  block: # bug #20695
    type
      Default = object
        tabs: Table[string, int] = initTable[string, int]()

    let d = default(Default)
    doAssert d.tabs.len == 0

  block:
    type
      Default = object
        tabs: Table[string, int] = Table[string, int]()

    let d = default(Default)
    doAssert d.tabs.len == 0


  block:
    type DjangoDateTime = distinct DateTime

    type Default = object
      data: DjangoDateTime = DjangoDateTime(DateTime())

    let x = default(Default)
    doAssert x.data is DjangoDateTime

  block:
    type DjangoDateTime = distinct DateTime

    type Default = object
      data = DjangoDateTime(DateTime())

    let x = default(Default)
    doAssert x.data is DjangoDateTime

  block:
    type
      Result2 = object
        case o: bool
        of false:
          e: float
        of true:
          v {.requiresInit.} : int = 1

    proc startSessionSync(): Result2 =
      return Result2(o: true)

    proc mainSync =
      let ff = startSessionSync()
      doAssert ff.v == 1

    mainSync()

  block:
    type
      Result2 = object
        v {.requiresInit.} : int = 1

    proc startSessionSync(): Result2 =
      return Result2()

    proc mainSync =
      let ff = startSessionSync()
      doAssert ff.v == 1

    mainSync()

  block: # bug #21801
    func evaluate(i: int): float =
      0.0

    func evaluate(): float =
      0.0

    type SearchOptions = object
        evaluation: proc(): float = evaluate

  block:
    func evaluate(): float =
      0.0

    type SearchOptions = object
        evaluation: proc(): float = evaluate

  block:
    func evaluate(i: int): float =
      0.0

    type SearchOptions = object
        evaluation = evaluate
  block:
    type
      Result[T, E] = object
        when T is void:
          when E is void:
            oResultPrivate: bool
          else:
            case oResultPrivate: bool
            of false:
              eResultPrivate: E
            of true:
              discard
        else:
          when E is void:
            case oResultPrivate: bool
            of false:
              discard
            of true:
              vResultPrivate: T
          else:
            case oResultPrivate: bool
            of false:
              eResultPrivate: E
            of true:
              vResultPrivate: T


    template `?`[T, E](self: Result[T, E]): auto =
      let v = (self)
      if not v.oResultPrivate:
        when compiles(`assignResult?`(default(typeof(result)))):
          when typeof(result) is typeof(v):
            `assignResult?`(v)
          elif E is void:
            `assignResult?`(err(typeof(result)))
          else:
            `assignResult?`(err(typeof(result), v.eResultPrivate))
          return
        else:
          return
            when typeof(result) is typeof(v):
              v
            elif E is void:
              err(typeof(result))
            else:
              err(typeof(result), v.eResultPrivate)

      when not(T is void):
        v.vResultPrivate
        
    type R = Result[int, string]

    proc testAssignResult() =
      var assigned: bool
      template `assignResult?`(v: Result) =
        assigned = true
        result = v

      proc failed(): Result[int, string] =
        discard

      proc calling(): Result[int, string] =
        let _ = ? failed()
        doAssert false

      let r = calling()
      doAssert assigned

    when nimvm:
      when not defined(js):
        testAssignResult()
    else:
      testAssignResult()

  block: # bug #22123
    type Thing = object
      x: float32 = 1

    type ThingWithArray = object
        arr: array[256, float32]
        n: float32 = 1

    type Container = ref object
        thing: array[5, Thing]
        thing_with_array: array[5, ThingWithArray]

    var foo = new Container
    doAssert int(foo.thing[0].x) == 1

  block: # bug #22613
    type
      K = enum
        A = "a"
        B = "b"
      T = object
        case kind: K = B
        of A:
          a: int
        of B:
          b: float

    doAssert T().kind == B

  block: # bug #22926
    type
      Direction = enum
        North
        South
        East
        West

      ArrayObj1 = object
        list: array[Direction, int]

      ArrayObj2 = object
        list: array[Direction, int] = [1, 2, 3, 4]

    block:
      var a: ArrayObj1
      doAssert a.list[West] == 0
      var b = default ArrayObj1
      doAssert b.list[North] == 0


    block:
      var a: ArrayObj2
      doAssert a.list[West] == 0
      var b = default ArrayObj2
      doAssert b.list[North] == 1

  block:
    type limited_float = range[1.2..20.0]
    doAssert default(limited_float) == 1.2


  block:
    type
      range1 = range[1..10]
      range2 = range[-1..10]

    proc foo =
      doAssert default(range1) == 1
      doAssert default(range2) == -1

      let s = default(array[5, range1])
      doAssert s == [range1 1, 1, 1, 1, 1]

    foo()

  block:
    type
      Object = object
        id: range[1.2..29.3]

    var s = default(Object)
    doAssert s.id == 1.2

  block: # bug #23943
    type limited_int = range[1..20]
    var d: limited_int;
    doAssert d == 1

static: main()
main()