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

**URL:** https://discourse.julialang.org/t/i-dont-see-any-caveats-in-setfield-jl-accessors-jl-but-im-getting-a-method/54657
**Category:** General Usage
**Tags:** accessors
**Created:** [February 4, 2021, 10:06pm UTC](https://discourse.julialang.org/t/i-dont-see-any-caveats-in-setfield-jl-accessors-jl-but-im-getting-a-method/54657 "2021-02-04T22:06:06Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![charleskawczynski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/charleskawczynski/32/13783_2.png) [@charleskawczynski](https://discourse.julialang.org/u/charleskawczynski)
#### Post date: [February 4, 2021, 11:14pm UTC](https://discourse.julialang.org/t/i-dont-see-any-caveats-in-setfield-jl-accessors-jl-but-im-getting-a-method/54657/3 "2021-02-04T23:14:34Z")

</div>

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

```julia
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)

```

---

_[View the full topic](https://discourse.julialang.org/t/i-dont-see-any-caveats-in-setfield-jl-accessors-jl-but-im-getting-a-method/54657)._
