Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.970 backport] flush keepalives on operator assignment statements #13151

Merged
merged 1 commit into from Jul 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions mypyc/irbuild/statement.py
Expand Up @@ -136,6 +136,7 @@ def transform_operator_assignment_stmt(builder: IRBuilder, stmt: OperatorAssignm
# usually operator assignments are done in-place
# but when target doesn't support that we need to manually assign
builder.assign(target, res, res.line)
builder.flush_keep_alives()


def transform_import(builder: IRBuilder, node: Import) -> None:
Expand Down
12 changes: 12 additions & 0 deletions mypyc/test-data/run-generators.test
Expand Up @@ -595,3 +595,15 @@ class C:
self.foo.flag = True
yield
self.foo.flag = False

[case testGeneratorEarlyReturnWithBorrows]
from typing import Iterator
class Bar:
bar = 0
class Foo:
bar = Bar()
def f(self) -> Iterator[int]:
if self:
self.bar.bar += 1
return
yield 0