We are getting a strange error message with a custom static vector of Dual:
DimensionMismatch: No precise constructor for Vec{2, Quantity{T, π, Unitful.FreeUnits{(m,), π, nothing}} where T} found. Length of input was 2.
Stacktrace:
[1] _no_precise_size(SA::Type, x::Tuple{Quantity{ForwardDiff.Dual{ForwardDiff.Tag{Meshes.var"#f#376"{Box{πΌ{2}, Cartesian2D{NoDatum, Quantity{Float64, π, Unitful.FreeUnits{(m,), π, nothing}}}}, Tuple{Float64, Float64}, Int64, Int64}, Float64}, Float64, 1}, π, Unitful.FreeUnits{(m,), π, nothing}}, Quantity{Float64, π, Unitful.FreeUnits{(m,), π, nothing}}})
@ StaticArrays ~/.julia/packages/StaticArrays/0cEwi/src/convert.jl:169
[2] construct_type(::Type{Vec{2, Quantity{T, π, Unitful.FreeUnits{(m,), π, nothing}} where T}}, x::StaticArrays.Args{Tuple{Tuple{Tuple{Quantity{ForwardDiff.Dual{ForwardDiff.Tag{Meshes.var"#f#376"{Box{πΌ{2}, Cartesian2D{NoDatum, Quantity{Float64, π, Unitful.FreeUnits{(m,), π, nothing}}}}, Tuple{Float64, Float64}, Int64, Int64}, Float64}, Float64, 1}, π, Unitful.FreeUnits{(m,), π, nothing}}, Quantity{Float64, π, Unitful.FreeUnits{(m,), π, nothing}}}}}})
@ StaticArrays ~/.julia/packages/StaticArrays/0cEwi/src/convert.jl:89
[3] StaticArray (repeats 2 times)
@ ~/.julia/packages/StaticArrays/0cEwi/src/convert.jl:173 [inlined]
[4] _broadcast
@ ~/.julia/packages/StaticArrays/0cEwi/src/broadcast.jl:120 [inlined]
[5] copy
@ ~/.julia/packages/StaticArrays/0cEwi/src/broadcast.jl:60 [inlined]
[6] materialize
@ ./broadcast.jl:894 [inlined]
[7] (::Box{πΌ{2}, Cartesian2D{NoDatum, Quantity{Float64, π, Unitful.FreeUnits{(m,), π, nothing}}}})(::ForwardDiff.Dual{ForwardDiff.Tag{Meshes.var"#f#376"{Box{πΌ{2}, Cartesian2D{NoDatum, Quantity{Float64, π, Unitful.FreeUnits{(m,), π, nothing}}}}, Tuple{Float64, Float64}, Int64, Int64}, Float64}, Float64, 1}, ::Float64)
@ Meshes ~/.julia/dev/Meshes/src/geometries/primitives/box.jl:63
If you pull the PR at https://github.com/JuliaGeometry/Meshes.jl/pull/1347, you can reproduce the error with the following code:
using Meshes
integral(p -> 1, Box((0, 0), (1, 1)))
It works fine if we run the example with 1D boxes (i.e., coordinate vectors of length 1):
integraintegral(p -> 1, Box((0,), (1,)))
So I am assuming the issue must be related to our custom Vec definition:
https://github.com/JuliaGeometry/Meshes.jl/blob/master/src/vectors.jl
Do we need to add a method for StaticArrays.construct_type?
Appreciate any help.
Last updated: Apr 21 2026 at 06:18 UTC