File: irbuild-nested.test

package info (click to toggle)
mypy 0.812-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 18,596 kB
  • sloc: python: 74,869; cpp: 11,212; ansic: 3,935; makefile: 238; sh: 13
file content (862 lines) | stat: -rw-r--r-- 20,706 bytes parent folder | download
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
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
[case testNestedFunctions]
from typing import Callable

def a() -> Callable[[], object]:
    def inner() -> object:
        return None
    return inner

def b() -> Callable[[], Callable[[], str]]:
    def first() -> Callable[[], str]:
        def second() -> str:
            return 'b.first.second: nested function'
        return second
    return first

def c(num: float) -> Callable[[str], str]:
    def inner(s: str) -> str:
        return s + '!'
    return inner

def d(num: float) -> str:
    def inner(s: str) -> str:
        return s + '?'
    a = inner('one')
    b = inner('two')
    return a

def inner() -> str:
    return 'inner: normal function'

def first() -> str:
    return 'first: normal function'

def second() -> str:
    return 'second: normal function'
[out]
def inner_a_obj.__get__(__mypyc_self__, instance, owner):
    __mypyc_self__, instance, owner, r0 :: object
    r1 :: bit
    r2 :: object
L0:
    r0 = load_address _Py_NoneStruct
    r1 = instance == r0
    if r1 goto L1 else goto L2 :: bool
L1:
    return __mypyc_self__
L2:
    r2 = PyMethod_New(__mypyc_self__, instance)
    return r2
def inner_a_obj.__call__(__mypyc_self__):
    __mypyc_self__ :: __main__.inner_a_obj
    r0 :: __main__.a_env
    r1, inner, r2 :: object
L0:
    r0 = __mypyc_self__.__mypyc_env__
    r1 = r0.inner
    inner = r1
    r2 = box(None, 1)
    return r2
def a():
    r0 :: __main__.a_env
    r1 :: __main__.inner_a_obj
    r2, r3 :: bool
    r4 :: object
L0:
    r0 = a_env()
    r1 = inner_a_obj()
    r1.__mypyc_env__ = r0; r2 = is_error
    r0.inner = r1; r3 = is_error
    r4 = r0.inner
    return r4
def second_b_first_obj.__get__(__mypyc_self__, instance, owner):
    __mypyc_self__, instance, owner, r0 :: object
    r1 :: bit
    r2 :: object
L0:
    r0 = load_address _Py_NoneStruct
    r1 = instance == r0
    if r1 goto L1 else goto L2 :: bool
L1:
    return __mypyc_self__
L2:
    r2 = PyMethod_New(__mypyc_self__, instance)
    return r2
def second_b_first_obj.__call__(__mypyc_self__):
    __mypyc_self__ :: __main__.second_b_first_obj
    r0 :: __main__.first_b_env
    r1 :: __main__.b_env
    r2, second :: object
    r3 :: str
L0:
    r0 = __mypyc_self__.__mypyc_env__
    r1 = r0.__mypyc_env__
    r2 = r0.second
    second = r2
    r3 = load_global CPyStatic_unicode_3 :: static  ('b.first.second: nested function')
    return r3
def first_b_obj.__get__(__mypyc_self__, instance, owner):
    __mypyc_self__, instance, owner, r0 :: object
    r1 :: bit
    r2 :: object
L0:
    r0 = load_address _Py_NoneStruct
    r1 = instance == r0
    if r1 goto L1 else goto L2 :: bool
L1:
    return __mypyc_self__
L2:
    r2 = PyMethod_New(__mypyc_self__, instance)
    return r2
def first_b_obj.__call__(__mypyc_self__):
    __mypyc_self__ :: __main__.first_b_obj
    r0 :: __main__.b_env
    r1, first :: object
    r2 :: __main__.first_b_env
    r3 :: bool
    r4 :: __main__.second_b_first_obj
    r5, r6 :: bool
    r7 :: object
L0:
    r0 = __mypyc_self__.__mypyc_env__
    r1 = r0.first
    first = r1
    r2 = first_b_env()
    r2.__mypyc_env__ = r0; r3 = is_error
    r4 = second_b_first_obj()
    r4.__mypyc_env__ = r2; r5 = is_error
    r2.second = r4; r6 = is_error
    r7 = r2.second
    return r7
def b():
    r0 :: __main__.b_env
    r1 :: __main__.first_b_obj
    r2, r3 :: bool
    r4 :: object
L0:
    r0 = b_env()
    r1 = first_b_obj()
    r1.__mypyc_env__ = r0; r2 = is_error
    r0.first = r1; r3 = is_error
    r4 = r0.first
    return r4
def inner_c_obj.__get__(__mypyc_self__, instance, owner):
    __mypyc_self__, instance, owner, r0 :: object
    r1 :: bit
    r2 :: object
L0:
    r0 = load_address _Py_NoneStruct
    r1 = instance == r0
    if r1 goto L1 else goto L2 :: bool
L1:
    return __mypyc_self__
L2:
    r2 = PyMethod_New(__mypyc_self__, instance)
    return r2
def inner_c_obj.__call__(__mypyc_self__, s):
    __mypyc_self__ :: __main__.inner_c_obj
    s :: str
    r0 :: __main__.c_env
    r1, inner :: object
    r2, r3 :: str
L0:
    r0 = __mypyc_self__.__mypyc_env__
    r1 = r0.inner
    inner = r1
    r2 = load_global CPyStatic_unicode_4 :: static  ('!')
    r3 = PyUnicode_Concat(s, r2)
    return r3
def c(num):
    num :: float
    r0 :: __main__.c_env
    r1 :: __main__.inner_c_obj
    r2, r3 :: bool
    r4 :: object
L0:
    r0 = c_env()
    r1 = inner_c_obj()
    r1.__mypyc_env__ = r0; r2 = is_error
    r0.inner = r1; r3 = is_error
    r4 = r0.inner
    return r4
def inner_d_obj.__get__(__mypyc_self__, instance, owner):
    __mypyc_self__, instance, owner, r0 :: object
    r1 :: bit
    r2 :: object
L0:
    r0 = load_address _Py_NoneStruct
    r1 = instance == r0
    if r1 goto L1 else goto L2 :: bool
L1:
    return __mypyc_self__
L2:
    r2 = PyMethod_New(__mypyc_self__, instance)
    return r2
def inner_d_obj.__call__(__mypyc_self__, s):
    __mypyc_self__ :: __main__.inner_d_obj
    s :: str
    r0 :: __main__.d_env
    r1, inner :: object
    r2, r3 :: str
L0:
    r0 = __mypyc_self__.__mypyc_env__
    r1 = r0.inner
    inner = r1
    r2 = load_global CPyStatic_unicode_5 :: static  ('?')
    r3 = PyUnicode_Concat(s, r2)
    return r3
def d(num):
    num :: float
    r0 :: __main__.d_env
    r1 :: __main__.inner_d_obj
    r2, r3 :: bool
    r4 :: str
    r5, r6 :: object
    r7, a, r8 :: str
    r9, r10 :: object
    r11, b :: str
L0:
    r0 = d_env()
    r1 = inner_d_obj()
    r1.__mypyc_env__ = r0; r2 = is_error
    r0.inner = r1; r3 = is_error
    r4 = load_global CPyStatic_unicode_6 :: static  ('one')
    r5 = r0.inner
    r6 = PyObject_CallFunctionObjArgs(r5, r4, 0)
    r7 = cast(str, r6)
    a = r7
    r8 = load_global CPyStatic_unicode_7 :: static  ('two')
    r9 = r0.inner
    r10 = PyObject_CallFunctionObjArgs(r9, r8, 0)
    r11 = cast(str, r10)
    b = r11
    return a
def inner():
    r0 :: str
L0:
    r0 = load_global CPyStatic_unicode_8 :: static  ('inner: normal function')
    return r0
def first():
    r0 :: str
L0:
    r0 = load_global CPyStatic_unicode_9 :: static  ('first: normal function')
    return r0
def second():
    r0 :: str
L0:
    r0 = load_global CPyStatic_unicode_10 :: static  ('second: normal function')
    return r0

[case testFreeVars]
from typing import Callable

def a(num: int) -> int:
    def inner() -> int:
        return num
    return inner()

def b() -> int:
    num = 3
    def inner() -> int:
        nonlocal num
        num = 4
        foo = 6
        return num
    return inner() + num

def c(flag: bool) -> str:
    if flag:
        def inner() -> str:
            return 'f.inner: first definition'
    else:
        def inner() -> str:
            return 'f.inner: second definition'
    return inner()

[out]
def inner_a_obj.__get__(__mypyc_self__, instance, owner):
    __mypyc_self__, instance, owner, r0 :: object
    r1 :: bit
    r2 :: object
L0:
    r0 = load_address _Py_NoneStruct
    r1 = instance == r0
    if r1 goto L1 else goto L2 :: bool
L1:
    return __mypyc_self__
L2:
    r2 = PyMethod_New(__mypyc_self__, instance)
    return r2
def inner_a_obj.__call__(__mypyc_self__):
    __mypyc_self__ :: __main__.inner_a_obj
    r0 :: __main__.a_env
    r1, inner :: object
    r2 :: int
L0:
    r0 = __mypyc_self__.__mypyc_env__
    r1 = r0.inner
    inner = r1
    r2 = r0.num
    return r2
def a(num):
    num :: int
    r0 :: __main__.a_env
    r1 :: bool
    r2 :: __main__.inner_a_obj
    r3, r4 :: bool
    r5, r6 :: object
    r7 :: int
L0:
    r0 = a_env()
    r0.num = num; r1 = is_error
    r2 = inner_a_obj()
    r2.__mypyc_env__ = r0; r3 = is_error
    r0.inner = r2; r4 = is_error
    r5 = r0.inner
    r6 = PyObject_CallFunctionObjArgs(r5, 0)
    r7 = unbox(int, r6)
    return r7
def inner_b_obj.__get__(__mypyc_self__, instance, owner):
    __mypyc_self__, instance, owner, r0 :: object
    r1 :: bit
    r2 :: object
L0:
    r0 = load_address _Py_NoneStruct
    r1 = instance == r0
    if r1 goto L1 else goto L2 :: bool
L1:
    return __mypyc_self__
L2:
    r2 = PyMethod_New(__mypyc_self__, instance)
    return r2
def inner_b_obj.__call__(__mypyc_self__):
    __mypyc_self__ :: __main__.inner_b_obj
    r0 :: __main__.b_env
    r1, inner :: object
    r2 :: bool
    foo, r3 :: int
L0:
    r0 = __mypyc_self__.__mypyc_env__
    r1 = r0.inner
    inner = r1
    r0.num = 8; r2 = is_error
    foo = 12
    r3 = r0.num
    return r3
def b():
    r0 :: __main__.b_env
    r1 :: bool
    r2 :: __main__.inner_b_obj
    r3, r4 :: bool
    r5, r6 :: object
    r7, r8, r9 :: int
L0:
    r0 = b_env()
    r0.num = 6; r1 = is_error
    r2 = inner_b_obj()
    r2.__mypyc_env__ = r0; r3 = is_error
    r0.inner = r2; r4 = is_error
    r5 = r0.inner
    r6 = PyObject_CallFunctionObjArgs(r5, 0)
    r7 = unbox(int, r6)
    r8 = r0.num
    r9 = CPyTagged_Add(r7, r8)
    return r9
def inner_c_obj.__get__(__mypyc_self__, instance, owner):
    __mypyc_self__, instance, owner, r0 :: object
    r1 :: bit
    r2 :: object
L0:
    r0 = load_address _Py_NoneStruct
    r1 = instance == r0
    if r1 goto L1 else goto L2 :: bool
L1:
    return __mypyc_self__
L2:
    r2 = PyMethod_New(__mypyc_self__, instance)
    return r2
def inner_c_obj.__call__(__mypyc_self__):
    __mypyc_self__ :: __main__.inner_c_obj
    r0 :: __main__.c_env
    r1, inner :: object
    r2 :: str
L0:
    r0 = __mypyc_self__.__mypyc_env__
    r1 = r0.inner
    inner = r1
    r2 = load_global CPyStatic_unicode_3 :: static  ('f.inner: first definition')
    return r2
def inner_c_obj_0.__get__(__mypyc_self__, instance, owner):
    __mypyc_self__, instance, owner, r0 :: object
    r1 :: bit
    r2 :: object
L0:
    r0 = load_address _Py_NoneStruct
    r1 = instance == r0
    if r1 goto L1 else goto L2 :: bool
L1:
    return __mypyc_self__
L2:
    r2 = PyMethod_New(__mypyc_self__, instance)
    return r2
def inner_c_obj_0.__call__(__mypyc_self__):
    __mypyc_self__ :: __main__.inner_c_obj_0
    r0 :: __main__.c_env
    r1, inner :: object
    r2 :: str
L0:
    r0 = __mypyc_self__.__mypyc_env__
    r1 = r0.inner
    inner = r1
    r2 = load_global CPyStatic_unicode_4 :: static  ('f.inner: second definition')
    return r2
def c(flag):
    flag :: bool
    r0 :: __main__.c_env
    r1 :: __main__.inner_c_obj
    r2, r3 :: bool
    r4 :: __main__.inner_c_obj_0
    r5, r6 :: bool
    r7, r8 :: object
    r9 :: str
L0:
    r0 = c_env()
    if flag goto L1 else goto L2 :: bool
L1:
    r1 = inner_c_obj()
    r1.__mypyc_env__ = r0; r2 = is_error
    r0.inner = r1; r3 = is_error
    goto L3
L2:
    r4 = inner_c_obj_0()
    r4.__mypyc_env__ = r0; r5 = is_error
    r0.inner = r4; r6 = is_error
L3:
    r7 = r0.inner
    r8 = PyObject_CallFunctionObjArgs(r7, 0)
    r9 = cast(str, r8)
    return r9

[case testSpecialNested]
def a() -> int:
    x = 1
    def b() -> int:
        x += 1
        def c() -> int:
            return x
        return c()
    return b()

[out]
def c_a_b_obj.__get__(__mypyc_self__, instance, owner):
    __mypyc_self__, instance, owner, r0 :: object
    r1 :: bit
    r2 :: object
L0:
    r0 = load_address _Py_NoneStruct
    r1 = instance == r0
    if r1 goto L1 else goto L2 :: bool
L1:
    return __mypyc_self__
L2:
    r2 = PyMethod_New(__mypyc_self__, instance)
    return r2
def c_a_b_obj.__call__(__mypyc_self__):
    __mypyc_self__ :: __main__.c_a_b_obj
    r0 :: __main__.b_a_env
    r1 :: __main__.a_env
    r2, c :: object
    r3 :: int
L0:
    r0 = __mypyc_self__.__mypyc_env__
    r1 = r0.__mypyc_env__
    r2 = r0.c
    c = r2
    r3 = r1.x
    return r3
def b_a_obj.__get__(__mypyc_self__, instance, owner):
    __mypyc_self__, instance, owner, r0 :: object
    r1 :: bit
    r2 :: object
L0:
    r0 = load_address _Py_NoneStruct
    r1 = instance == r0
    if r1 goto L1 else goto L2 :: bool
L1:
    return __mypyc_self__
L2:
    r2 = PyMethod_New(__mypyc_self__, instance)
    return r2
def b_a_obj.__call__(__mypyc_self__):
    __mypyc_self__ :: __main__.b_a_obj
    r0 :: __main__.a_env
    r1, b :: object
    r2 :: __main__.b_a_env
    r3 :: bool
    r4, r5 :: int
    r6 :: bool
    r7 :: __main__.c_a_b_obj
    r8, r9 :: bool
    r10, r11 :: object
    r12 :: int
L0:
    r0 = __mypyc_self__.__mypyc_env__
    r1 = r0.b
    b = r1
    r2 = b_a_env()
    r2.__mypyc_env__ = r0; r3 = is_error
    r4 = r0.x
    r5 = CPyTagged_Add(r4, 2)
    r0.x = r5; r6 = is_error
    r7 = c_a_b_obj()
    r7.__mypyc_env__ = r2; r8 = is_error
    r2.c = r7; r9 = is_error
    r10 = r2.c
    r11 = PyObject_CallFunctionObjArgs(r10, 0)
    r12 = unbox(int, r11)
    return r12
def a():
    r0 :: __main__.a_env
    r1 :: bool
    r2 :: __main__.b_a_obj
    r3, r4 :: bool
    r5, r6 :: object
    r7 :: int
L0:
    r0 = a_env()
    r0.x = 2; r1 = is_error
    r2 = b_a_obj()
    r2.__mypyc_env__ = r0; r3 = is_error
    r0.b = r2; r4 = is_error
    r5 = r0.b
    r6 = PyObject_CallFunctionObjArgs(r5, 0)
    r7 = unbox(int, r6)
    return r7

[case testNestedFunctionInsideStatements]
def f(flag: bool) -> str:
    if flag:
        def inner() -> str:
            return 'f.inner: first definition'
    else:
        def inner() -> str:
            return 'f.inner: second definition'
    return inner()
[out]
def inner_f_obj.__get__(__mypyc_self__, instance, owner):
    __mypyc_self__, instance, owner, r0 :: object
    r1 :: bit
    r2 :: object
L0:
    r0 = load_address _Py_NoneStruct
    r1 = instance == r0
    if r1 goto L1 else goto L2 :: bool
L1:
    return __mypyc_self__
L2:
    r2 = PyMethod_New(__mypyc_self__, instance)
    return r2
def inner_f_obj.__call__(__mypyc_self__):
    __mypyc_self__ :: __main__.inner_f_obj
    r0 :: __main__.f_env
    r1, inner :: object
    r2 :: str
L0:
    r0 = __mypyc_self__.__mypyc_env__
    r1 = r0.inner
    inner = r1
    r2 = load_global CPyStatic_unicode_1 :: static  ('f.inner: first definition')
    return r2
def inner_f_obj_0.__get__(__mypyc_self__, instance, owner):
    __mypyc_self__, instance, owner, r0 :: object
    r1 :: bit
    r2 :: object
L0:
    r0 = load_address _Py_NoneStruct
    r1 = instance == r0
    if r1 goto L1 else goto L2 :: bool
L1:
    return __mypyc_self__
L2:
    r2 = PyMethod_New(__mypyc_self__, instance)
    return r2
def inner_f_obj_0.__call__(__mypyc_self__):
    __mypyc_self__ :: __main__.inner_f_obj_0
    r0 :: __main__.f_env
    r1, inner :: object
    r2 :: str
L0:
    r0 = __mypyc_self__.__mypyc_env__
    r1 = r0.inner
    inner = r1
    r2 = load_global CPyStatic_unicode_2 :: static  ('f.inner: second definition')
    return r2
def f(flag):
    flag :: bool
    r0 :: __main__.f_env
    r1 :: __main__.inner_f_obj
    r2, r3 :: bool
    r4 :: __main__.inner_f_obj_0
    r5, r6 :: bool
    r7, r8 :: object
    r9 :: str
L0:
    r0 = f_env()
    if flag goto L1 else goto L2 :: bool
L1:
    r1 = inner_f_obj()
    r1.__mypyc_env__ = r0; r2 = is_error
    r0.inner = r1; r3 = is_error
    goto L3
L2:
    r4 = inner_f_obj_0()
    r4.__mypyc_env__ = r0; r5 = is_error
    r0.inner = r4; r6 = is_error
L3:
    r7 = r0.inner
    r8 = PyObject_CallFunctionObjArgs(r7, 0)
    r9 = cast(str, r8)
    return r9

[case testNestedFunctionsCallEachOther]
from typing import Callable, List

def f(a: int) -> int:
    def foo() -> int:
        return a + 1

    def bar() -> int:
        return foo()

    def baz(n: int) -> int:
        if n == 0:
            return 0
        return n + baz(n - 1)

    return bar() + baz(a)

[out]
def foo_f_obj.__get__(__mypyc_self__, instance, owner):
    __mypyc_self__, instance, owner, r0 :: object
    r1 :: bit
    r2 :: object
L0:
    r0 = load_address _Py_NoneStruct
    r1 = instance == r0
    if r1 goto L1 else goto L2 :: bool
L1:
    return __mypyc_self__
L2:
    r2 = PyMethod_New(__mypyc_self__, instance)
    return r2
def foo_f_obj.__call__(__mypyc_self__):
    __mypyc_self__ :: __main__.foo_f_obj
    r0 :: __main__.f_env
    r1, foo :: object
    r2, r3 :: int
L0:
    r0 = __mypyc_self__.__mypyc_env__
    r1 = r0.foo
    foo = r1
    r2 = r0.a
    r3 = CPyTagged_Add(r2, 2)
    return r3
def bar_f_obj.__get__(__mypyc_self__, instance, owner):
    __mypyc_self__, instance, owner, r0 :: object
    r1 :: bit
    r2 :: object
L0:
    r0 = load_address _Py_NoneStruct
    r1 = instance == r0
    if r1 goto L1 else goto L2 :: bool
L1:
    return __mypyc_self__
L2:
    r2 = PyMethod_New(__mypyc_self__, instance)
    return r2
def bar_f_obj.__call__(__mypyc_self__):
    __mypyc_self__ :: __main__.bar_f_obj
    r0 :: __main__.f_env
    r1, bar, r2, r3 :: object
    r4 :: int
L0:
    r0 = __mypyc_self__.__mypyc_env__
    r1 = r0.bar
    bar = r1
    r2 = r0.foo
    r3 = PyObject_CallFunctionObjArgs(r2, 0)
    r4 = unbox(int, r3)
    return r4
def baz_f_obj.__get__(__mypyc_self__, instance, owner):
    __mypyc_self__, instance, owner, r0 :: object
    r1 :: bit
    r2 :: object
L0:
    r0 = load_address _Py_NoneStruct
    r1 = instance == r0
    if r1 goto L1 else goto L2 :: bool
L1:
    return __mypyc_self__
L2:
    r2 = PyMethod_New(__mypyc_self__, instance)
    return r2
def baz_f_obj.__call__(__mypyc_self__, n):
    __mypyc_self__ :: __main__.baz_f_obj
    n :: int
    r0 :: __main__.f_env
    r1, baz :: object
    r2 :: bit
    r3 :: int
    r4, r5 :: object
    r6, r7 :: int
L0:
    r0 = __mypyc_self__.__mypyc_env__
    r1 = r0.baz
    baz = r1
    r2 = n == 0
    if r2 goto L1 else goto L2 :: bool
L1:
    return 0
L2:
    r3 = CPyTagged_Subtract(n, 2)
    r4 = box(int, r3)
    r5 = PyObject_CallFunctionObjArgs(baz, r4, 0)
    r6 = unbox(int, r5)
    r7 = CPyTagged_Add(n, r6)
    return r7
def f(a):
    a :: int
    r0 :: __main__.f_env
    r1 :: bool
    r2 :: __main__.foo_f_obj
    r3, r4 :: bool
    r5 :: __main__.bar_f_obj
    r6, r7 :: bool
    r8 :: __main__.baz_f_obj
    r9, r10 :: bool
    r11, r12 :: object
    r13, r14 :: int
    r15, r16, r17 :: object
    r18, r19 :: int
L0:
    r0 = f_env()
    r0.a = a; r1 = is_error
    r2 = foo_f_obj()
    r2.__mypyc_env__ = r0; r3 = is_error
    r0.foo = r2; r4 = is_error
    r5 = bar_f_obj()
    r5.__mypyc_env__ = r0; r6 = is_error
    r0.bar = r5; r7 = is_error
    r8 = baz_f_obj()
    r8.__mypyc_env__ = r0; r9 = is_error
    r0.baz = r8; r10 = is_error
    r11 = r0.bar
    r12 = PyObject_CallFunctionObjArgs(r11, 0)
    r13 = unbox(int, r12)
    r14 = r0.a
    r15 = r0.baz
    r16 = box(int, r14)
    r17 = PyObject_CallFunctionObjArgs(r15, r16, 0)
    r18 = unbox(int, r17)
    r19 = CPyTagged_Add(r13, r18)
    return r19

[case testLambdas]
def f(x: int, y: int) -> None:
    s = lambda a, b: a + b
    t = lambda a, b: s(a, b)
    return t(x, y)

[out]
def __mypyc_lambda__0_f_obj.__get__(__mypyc_self__, instance, owner):
    __mypyc_self__, instance, owner, r0 :: object
    r1 :: bit
    r2 :: object
L0:
    r0 = load_address _Py_NoneStruct
    r1 = instance == r0
    if r1 goto L1 else goto L2 :: bool
L1:
    return __mypyc_self__
L2:
    r2 = PyMethod_New(__mypyc_self__, instance)
    return r2
def __mypyc_lambda__0_f_obj.__call__(__mypyc_self__, a, b):
    __mypyc_self__ :: __main__.__mypyc_lambda__0_f_obj
    a, b :: object
    r0 :: __main__.f_env
    r1 :: object
L0:
    r0 = __mypyc_self__.__mypyc_env__
    r1 = PyNumber_Add(a, b)
    return r1
def __mypyc_lambda__1_f_obj.__get__(__mypyc_self__, instance, owner):
    __mypyc_self__, instance, owner, r0 :: object
    r1 :: bit
    r2 :: object
L0:
    r0 = load_address _Py_NoneStruct
    r1 = instance == r0
    if r1 goto L1 else goto L2 :: bool
L1:
    return __mypyc_self__
L2:
    r2 = PyMethod_New(__mypyc_self__, instance)
    return r2
def __mypyc_lambda__1_f_obj.__call__(__mypyc_self__, a, b):
    __mypyc_self__ :: __main__.__mypyc_lambda__1_f_obj
    a, b :: object
    r0 :: __main__.f_env
    r1, r2 :: object
L0:
    r0 = __mypyc_self__.__mypyc_env__
    r1 = r0.s
    r2 = PyObject_CallFunctionObjArgs(r1, a, b, 0)
    return r2
def f(x, y):
    x, y :: int
    r0 :: __main__.f_env
    r1 :: __main__.__mypyc_lambda__0_f_obj
    r2, r3 :: bool
    r4 :: __main__.__mypyc_lambda__1_f_obj
    r5 :: bool
    t, r6, r7, r8 :: object
    r9 :: None
L0:
    r0 = f_env()
    r1 = __mypyc_lambda__0_f_obj()
    r1.__mypyc_env__ = r0; r2 = is_error
    r0.s = r1; r3 = is_error
    r4 = __mypyc_lambda__1_f_obj()
    r4.__mypyc_env__ = r0; r5 = is_error
    t = r4
    r6 = box(int, x)
    r7 = box(int, y)
    r8 = PyObject_CallFunctionObjArgs(t, r6, r7, 0)
    r9 = unbox(None, r8)
    return r9

[case testRecursiveFunction]
from typing import Callable

def baz(n: int) -> int:
    if n == 0:
        return 0
    return n + baz(n - 1)

[out]
def baz(n):
    n :: int
    r0 :: bit
    r1, r2, r3 :: int
L0:
    r0 = n == 0
    if r0 goto L1 else goto L2 :: bool
L1:
    return 0
L2:
    r1 = CPyTagged_Subtract(n, 2)
    r2 = baz(r1)
    r3 = CPyTagged_Add(n, r2)
    return r3