Skip to content

Missing parameter-less constructor when using explicit type parameters #18

@AntonOresten

Description

@AntonOresten

I found myself wanting something like B(rand(1)), but it seems that method doesn't get defined. See #17

julia> struct A{T}
           x::Vector{T}
       end

julia> A(rand(1))
A{Float64}([0.7610381409441728])

julia> A{Float64}(rand(1))
A{Float64}([0.5092874009390502])

julia> using ConcreteStructs

julia> @concrete struct B{T}
           x <: Vector{T}
       end

julia> B(rand(1))
ERROR: MethodError: no method matching B(::Vector{Float64})
The type `B` exists, but no method is defined for this combination of argument types when trying to construct it.
Stacktrace:
 [1] top-level scope
   @ REPL[6]:1

julia> B{Float64}(rand(1))
B{Float64, Vector{Float64}}([0.038474710287414005])

julia> @concrete struct C{T}
           x::Vector{T}
       end

julia> C(rand(1))
C{Float64}([0.41418023308916496])

julia> C{Float64}(rand(1))
C{Float64}([0.7672194655197099])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions