Skip to content

dict function with distinct elements handled poorly #602

Closed as duplicate
Closed as duplicate

Description

@ndmitchell

Describe the Bug

dict(x = 1, y = "test")

Gives:

No matching overload found for function `dict.__init__`

Because we match the overload:

  (**kwargs: T) -> None

We instantiate T to int from the first item, then declare it incompatible with str for the second item.

This is a little unusual as most people doing that would be better off using a dictionary literal, which we do support well. Perhaps we should special case this form as dictionary initialisation too.

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Activity

  1. added theissue type on Jun 29, 2025
  2. yangdanny97 commented on Jun 29, 2025

    @yangdanny97
    Collaborator

    root cause seems to be #105

  3. ndmitchell commented on Jun 29, 2025

    @ndmitchell
    ContributorAuthor

    They have the same root cause. But one shows up super regularly, and one is a possibility that we could easily leave for a long period of time. We might want to solve dict with special casing.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions