I don't see any caveats in `Setfield.jl / Accessors.jl`, but I'm getting a method

It took a bit to track down what the problem was. It seems that certain constructors must exist:

struct Foo{FT,A,B}
a::A
b::B
end

Foo{FT}(a::A,b::B) where {FT,A,B} = Foo{FT,A,B}(a,b)

f = Foo{Float64}(1, (;x=1,y=2))

using Accessors

# Fails:
@set f.b = (;x=2,y=1)

# Need this definition:
Foo(a,b) = Foo{typeof(a),typeof(a),typeof(b)}(a,b)

# Now works:
@set f.b = (;x=2,y=1)
1 Like