Skip to content

Allow more things as type parameters? #33387

Open
@Keno

Description

@Keno

This works:

julia> struct Bar{T}
       end

julia> struct FooWithoutUnion
           x::Int
       end

julia> Bar{FooWithoutUnion(1)}
Bar{FooWithoutUnion(1)}

this doesnt:

julia> struct FooWithUnion
          x::Union{Int, Nothing}
       end

julia> Bar{FooWithUnion(1)}
ERROR: TypeError: in Type, in parameter, expected Type, got FooWithUnion
Stacktrace:
 [1] top-level scope at REPL[20]:1

Now that we treat unions of bitstypes basically as good as bitstypes it seems to me that there is no reason to disallow the latter.

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