I wonder why the following errors:
julia> Base.@kwdef mutable struct A1{F1}
a :: F1
b :: F1 = zero(F1)
end
julia> A1(a = 1.0)
ERROR: UndefVarError: F1 not defined
Stacktrace:
[1] (::Core.var"#kw#Type")(::NamedTuple{(:a,),Tuple{Float64}}, ::Type{A1}) at ./none:0
[2] top-level scope at REPL[32]:1
[3] eval(::Module, ::Any) at ./boot.jl:330
[4] eval_user_input(::Any, ::REPL.REPLBackend) at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/REPL/src/REPL.jl:86
[...]
The same happens when the struct
is defined using Parameters.jl
.
Is there a workaround (other than spelling out the type explicitly and redundantly as in A1{Float64}(a = 1.0)
?