In creating a struct with units I don’t have a problem if each field of the struct has units. I am running into an error when not all the fields have units. Can someone show me where I am going wrong.
# Test unit structures
using FlexUnits, .UnitRegistry
import FlexUnits: QuantFieldVector, DimsMod
mutable struct Foo{T} <: QuantFieldVector{2,T}
num::Integer
leng::Quantity{T, D"m"}
end
num = 2
leng = 2.2u"m"
F = Foo(; num, leng)
ERROR: MethodError: no method matching Foo(; num::Int64, leng::Quantity{Float64, StaticDims{m}})
This method does not support all of the given keyword arguments (and may not support any).
Closest candidates are:
Foo(::Integer, ::Quantity{T, StaticDims{m}}) where T got unsupported keyword arguments "num", "leng"
@ Main REPL[5]:2
(::Type{FA})(::Tuple) where FA<:StaticArraysCore.FieldArray got unsupported keyword arguments "num", "leng"
@ StaticArrays C:\Users\jakez\.julia\packages\StaticArrays\SXG7G\src\FieldArray.jl:2
(::Type{SA})(::Base.Generator) where SA<:StaticArraysCore.StaticArray got unsupported keyword arguments "num", "leng"
@ StaticArrays C:\Users\jakez\.julia\packages\StaticArrays\SXG7G\src\SArray.jl:57
...
Stacktrace:
[1] top-level scope
@ REPL[8]:1
ERROR: MethodError: no method matching Foo(; num::Int64, leng::Quantity{Float64, StaticDims{m}})
This method does not support all of the given keyword arguments (and may not support any).
Closest candidates are:
Foo(::Integer, ::Quantity{T, StaticDims{m}}) where T got unsupported keyword arguments "num", "leng"
@ Main c:\data\st\Julia\WinderCurves\examples\addseries\test.jl:44
(::Type{FA})(::Tuple) where FA<:StaticArraysCore.FieldArray got unsupported keyword arguments "num", "leng"
@ StaticArrays C:\Users\jakez\.julia\packages\StaticArrays\SXG7G\src\FieldArray.jl:2
(::Type{SA})(::Base.Generator) where SA<:StaticArraysCore.StaticArray got unsupported keyword arguments "num", "leng"
@ StaticArrays C:\Users\jakez\.julia\packages\StaticArrays\SXG7G\src\SArray.jl:57
...
Stacktrace:
[1] top-level scope
@ c:\data\st\Julia\WinderCurves\examples\addseries\test.jl:50
julia>