(builder: IRBuilder, block: Block)
| 135 | |
| 136 | |
| 137 | def 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 | |
| 158 | def transform_expression_stmt(builder: IRBuilder, stmt: ExpressionStmt) -> None: |
no test coverage detected
searching dependent graphs…