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

Fix small conditional overload regression #12336

Merged

Conversation

cdce8p
Copy link
Collaborator

@cdce8p cdce8p commented Mar 11, 2022

Description

We shouldn't merge conditional FuncDefs after an unconditional one. This matches the behavior pre 0.940.

from typing import overload
class A: ...
class B: ...

@overload
def f2(x: A) -> A: ...
@overload
def f2(x: B) -> B: ...
def f2(x): ...
if True:
    def f2(x): ...   # E: Name "f2" already defined on line ...

Closes #12335

Don't merge conditional FuncDef
after an unconditional one.
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@cdce8p cdce8p mentioned this pull request Mar 11, 2022
@JelleZijlstra JelleZijlstra merged commit 0fecec8 into python:master Mar 12, 2022
@cdce8p cdce8p deleted the fix-conditional-overload-regression branch March 12, 2022 01:27
JukkaL pushed a commit that referenced this pull request Mar 21, 2022
Don't merge conditional FuncDef
after an unconditional one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0.940: Condition can't be inferred, unable to merge overloads
2 participants