irbuild-unreachable.test 2.1 KB

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