Skip to content

lower bound interferes with typevar value inference #30713

@oxinabox

Description

@oxinabox

Consider the following:

struct XX end
struct YY end

bar(a::A, b::B, c::C) where Tuple{A,B}<:C<:Union{Tuple{XX,YY}, Tuple{YY,XX}} where A where B = C

@show bar(XX(), YY(), (XX(),YY()))

gives:

julia> @show bar(XX(), YY(), (XX(),YY()))
ERROR: UndefVarError: C not defined
Stacktrace:
 [1] bar(::XX, ::YY, ::Tuple{XX,YY}) at ./REPL[3]:1

Expected is to return Tuple{XX,YY}

Similarly:

julia> @show bar(YY(), XX(), (YY(),XX()))
ERROR: UndefVarError: C not defined
Stacktrace:
 [1] bar(::YY, ::XX, ::Tuple{YY,XX}) at ./REPL[3]:1

Expected is to return Tuple{YY,XX}

For interest:
bar(XX(), YY(), (XX(), XX()) and bar(XX(), XX(), (XX(), XX()) , and bar(XX(), XX(), (YY(),YY())) and bar(YY(), YY(), (YY(),YY())) and bar(YY(),XX(), (YY(),YY())) give method errors

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