Skip to content

One more bug with union math logic #5243

Closed

Description

@ilevkivskyi

Well, I have found another bug with union math in overloads, this time false negative:

from typing import Union, overload

@overload
def f(x: int, y: int) -> int: ...
@overload
def f(x: object, y: str) -> str: ...
def f(x):
    pass

x: Union[int, str]
y: Union[int, str]
f(x, y) # passes, but should fail because it never matches (str, int)

The problem is that make_simplified_union is used. On one hand this allows us to do unioning in more scenarios, on other hand it is dangerous for union counting in unioned args. I am not sure what to do. @Michael0x2a could you take care of this? (This is however not urgent, since this is a false negative.)

Activity

  1. self-assigned this
    on Jun 19, 2018
  2. Michael0x2a commented on Jun 19, 2018

    @Michael0x2a
    Collaborator

    Will do -- I'll take a look a little later today.

  3. self-assigned this
    on Jun 20, 2018
  4. ilevkivskyi commented on Jun 20, 2018

    @ilevkivskyi
    MemberAuthor

    Sorry, for overtaking, but I went ahead and now have a possible fix for this in a form of a change to a union math logic, so I am un-assigning you here, but I hope you will review my PR that I will open soon :-)

  5. Michael0x2a commented on Jun 20, 2018

    @Michael0x2a
    Collaborator

    No worries :)

    I haven't actually started writing any code for this, so this works out perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions