using Distributions
Uniform{Float32}(0.0,1.0)
ERROR: MethodError: no method matching Uniform{Float32}(::Float64, ::Float64)
Closest candidates are:
Uniform{Float32}(::T<:Real, ::T<:Real) where T<:Real at /home/dehaybe/.julia/packages/Distributions/tfkz4/src/univariate/continuous/uniform.jl:29
Stacktrace:
[1] top-level scope at none:0
I’m not looking for a fix here but I’d like to know why my Float64 arguments are not considered as subtypes of Real and why the closest candidate is not used.
It would be easy for Distributions.jl to add an additional inner constructor (or just replace the existing one) to make your original code work as intended:
Uniform{T}(a, b) where {T} = new{T}(a, b)
And I agree that the way Julia prints that method mismatch error is awkward. Is this on the latest version of Julia?