MCPcopy Index your code
hub / github.com/python/mypy / transform_block

Function transform_block

mypyc/irbuild/statement.py:137–155  ·  view source on GitHub ↗
(builder: IRBuilder, block: Block)

Source from the content-addressed store, hash-verified

135
136
137def transform_block(builder: IRBuilder, block: Block) -> None:
138 if not block.is_unreachable:
139 builder.block_reachable_stack.append(True)
140 for stmt in block.body:
141 builder.accept(stmt)
142 if not builder.block_reachable_stack[-1]:
143 # The rest of the block is unreachable, so skip it
144 break
145 builder.block_reachable_stack.pop()
146 # Raise a RuntimeError if we hit a non-empty unreachable block.
147 # Don't complain about empty unreachable blocks, since mypy inserts
148 # those after `if MYPY`.
149 elif block.body:
150 builder.add(
151 RaiseStandardError(
152 RaiseStandardError.RUNTIME_ERROR, "Reached allegedly unreachable code!", block.line
153 )
154 )
155 builder.add(Unreachable())
156
157
158def transform_expression_stmt(builder: IRBuilder, stmt: ExpressionStmt) -> None:

Callers 1

visit_blockMethod · 0.90

Calls 6

RaiseStandardErrorClass · 0.90
UnreachableClass · 0.90
appendMethod · 0.80
acceptMethod · 0.45
popMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…