Skip to content

Infer argument type from default value #3090

@Xandaros

Description

@Xandaros
def test(x:int, y=5):
    reveal_type(y)

This currently reveals the type as Any. I propose it should use the type inference instead and consider this int.
Perhaps making it optional with a flag, but this seems reasonable to me. I had actually assumed it already worked like this until I decided to verify just now.
It is kind of like initialising the variable, is it not?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions