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

Class Return

mypyc/ir/ops.py:494–520  ·  view source on GitHub ↗

Return a value from a function.

Source from the content-addressed store, hash-verified

492
493@final
494class Return(ControlOp):
495 """Return a value from a function."""
496
497 error_kind = ERR_NEVER
498
499 def __init__(
500 self, value: Value, line: int = -1, *, yield_target: BasicBlock | None = None
501 ) -> None:
502 super().__init__(line)
503 self.value = value
504 # If this return is created by a yield, keep track of the next
505 # basic block. This doesn't affect the code we generate but
506 # can feed into analysis that need to understand the
507 # *original* CFG.
508 self.yield_target = yield_target
509
510 def sources(self) -> list[Value]:
511 return [self.value]
512
513 def set_sources(self, new: list[Value]) -> None:
514 (self.value,) = new
515
516 def stolen(self) -> list[Value]:
517 return [self.value]
518
519 def accept(self, visitor: OpVisitor[T]) -> T:
520 return visitor.visit_return(self)
521
522
523@final

Calls

no outgoing calls

Tested by 12

test_valid_fnMethod · 0.72
test_valid_gotoMethod · 0.72
test_invalid_gotoMethod · 0.72
test_invalid_assignMethod · 0.72
test_duplicate_opMethod · 0.72
test_pprintMethod · 0.72
test_returnMethod · 0.72
test_simpleMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…