Skip to content

Signature matching for unbound type parameters #58899

Open
@MilesCranmer

Description

@MilesCranmer

Consider the following example:

julia> specializing_typeof(::T) where {T} = T;

julia> specializing_typeof(::Type{T}) where {T} = Type{T};

julia> specializing_typeof((Type{T} where {T}).body)
ERROR: UndefVarError: `T` not defined in static parameter matching
Suggestion: run Test.detect_unbound_args to detect method arguments that do not fully constrain a type parameter.
Stacktrace:

I don't understand why it matches the second signature and hits an error, when the first signature is actually a valid match for it. For example, if I didn't have the second method, I get

julia> specializing_typeof(::T) where {T} = T;

julia> specializing_typeof((Type{T} where {T}).body)
DataType

which seems right to me.

Is this behavior expected?

(On 1.11.5; I'm assuming it is also seen in other versions)

Metadata

Metadata

Assignees

No one assigned

    Labels

    types and dispatchTypes, subtyping and method dispatch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions