1# Test cases for unreachable expressions
2
3[case testUnreachableMemberExpr]
4import sys
5
6def f() -> None:
7    y = sys.platform == "x" and sys.version_info > (3, 5)
8[out]
9def f():
10    r0 :: object
11    r1 :: str
12    r2 :: object
13    r3, r4 :: str
14    r5 :: int32
15    r6 :: bit
16    r7 :: object
17    r8, r9, r10 :: bit
18    r11, r12 :: bool
19    r13 :: object
20    r14 :: str
21    r15 :: object
22    r16 :: tuple[int, int]
23    r17, r18 :: object
24    r19, y :: bool
25L0:
26    r0 = sys :: module
27    r1 = 'platform'
28    r2 = CPyObject_GetAttr(r0, r1)
29    r3 = cast(str, r2)
30    r4 = 'x'
31    r5 = PyUnicode_Compare(r3, r4)
32    r6 = r5 == -1
33    if r6 goto L1 else goto L3 :: bool
34L1:
35    r7 = PyErr_Occurred()
36    r8 = r7 != 0
37    if r8 goto L2 else goto L3 :: bool
38L2:
39    r9 = CPy_KeepPropagating()
40L3:
41    r10 = r5 == 0
42    if r10 goto L5 else goto L4 :: bool
43L4:
44    r11 = r10
45    goto L6
46L5:
47    r12 = raise RuntimeError('mypyc internal error: should be unreachable')
48    r13 = box(None, 1)
49    r14 = 'version_info'
50    r15 = CPyObject_GetAttr(r13, r14)
51    r16 = (6, 10)
52    r17 = box(tuple[int, int], r16)
53    r18 = PyObject_RichCompare(r15, r17, 4)
54    r19 = unbox(bool, r18)
55    r11 = r19
56L6:
57    y = r11
58    return 1
59
60[case testUnreachableNameExpr]
61import sys
62
63def f() -> None:
64    y = sys.platform == 'x' and foobar
65[out]
66def f():
67    r0 :: object
68    r1 :: str
69    r2 :: object
70    r3, r4 :: str
71    r5 :: int32
72    r6 :: bit
73    r7 :: object
74    r8, r9, r10 :: bit
75    r11, r12 :: bool
76    r13 :: object
77    r14, y :: bool
78L0:
79    r0 = sys :: module
80    r1 = 'platform'
81    r2 = CPyObject_GetAttr(r0, r1)
82    r3 = cast(str, r2)
83    r4 = 'x'
84    r5 = PyUnicode_Compare(r3, r4)
85    r6 = r5 == -1
86    if r6 goto L1 else goto L3 :: bool
87L1:
88    r7 = PyErr_Occurred()
89    r8 = r7 != 0
90    if r8 goto L2 else goto L3 :: bool
91L2:
92    r9 = CPy_KeepPropagating()
93L3:
94    r10 = r5 == 0
95    if r10 goto L5 else goto L4 :: bool
96L4:
97    r11 = r10
98    goto L6
99L5:
100    r12 = raise RuntimeError('mypyc internal error: should be unreachable')
101    r13 = box(None, 1)
102    r14 = unbox(bool, r13)
103    r11 = r14
104L6:
105    y = r11
106    return 1
107